Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(instrumentation-pg): Inline incubating constants from @opentelemetry/semantic-conventions #2599

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"dependencies": {
"@opentelemetry/core": "^1.26.0",
"@opentelemetry/instrumentation": "^0.56.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@opentelemetry/semantic-conventions": "^1.27.0",
"@opentelemetry/sql-common": "^0.40.1",
"@types/pg": "8.6.1",
"@types/pg-pool": "2.0.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import {
METRIC_DB_CLIENT_OPERATION_DURATION,
ATTR_DB_NAMESPACE,
ATTR_DB_OPERATION_NAME,
} from '@opentelemetry/semantic-conventions/incubating';
} from './semantic-conventions';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open-telemetry/opentelemetry-js#5182 (comment) suggested using semconv.ts; I went with semantic-conventions.ts since it directly matches the package name. Happy to use the other suggestion if that's strongly preferred.


export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConfig> {
private _operationDuration!: Histogram;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* These constants are considered experimental exports of `@opentelemetry/semantic-conventions`.
* They're being inlined until they're officially exported by `@opentelemetry/semantic-conventions`.
*/
Comment on lines +17 to +20
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This little comment will appear at the top of this file in other packages; let's workshop it if needed before it proliferates.


/**
* The number of connections that are currently in state described by the `state` attribute
*
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied these all in full, including the "experimental" warning. Happy to edit this to remove it desired.

*/
export declare const METRIC_DB_CLIENT_CONNECTION_COUNT: 'db.client.connection.count';

/**
* The number of pending requests for an open connection, cumulative for the entire pool
*
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export declare const METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS: 'db.client.connection.pending_requests';

/**
* Duration of database client operations.
*
* @note Batch operations **SHOULD** be recorded as a single operation.
*
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export declare const METRIC_DB_CLIENT_OPERATION_DURATION: 'db.client.operation.duration';

/**
* The name of the database, fully qualified within the server address and port.
*
* @example customers
*
* @example test.users
*
* @note If a database system has multiple namespace components, they **SHOULD** be concatenated (potentially using database system specific conventions) from most general to most specific namespace component, and more specific namespaces **SHOULD** **NOT** be captured without the more general namespaces, to ensure that "startswith" queries for the more general namespaces will be valid.
* Semantic conventions for individual database systems **SHOULD** document what `db.namespace` means in the context of that system.
* It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export declare const ATTR_DB_NAMESPACE: 'db.namespace';

/**
* The name of the operation or command being executed.
*
* @example findAndModify
*
* @example HMSET
*
* @example SELECT
*
* @note It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
* If the operation name is parsed from the query text, it **SHOULD** be the first operation name found in the query.
* For batch operations, if the individual operations are known to have the same operation name then that operation name **SHOULD** be used prepended by `BATCH `, otherwise `db.operation.name` **SHOULD** be `BATCH` or some other database system specific term if more applicable.
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export declare const ATTR_DB_OPERATION_NAME: 'db.operation.name';
Loading