Skip to content

Commit 4fb610d

Browse files
authored
chore(instrumentation-pg): have @opentelemetry/semantic-conventions package dependency with caret (^) version to sync with other instrumentation packages (#2664)
Refs: #2599 (similar work)
1 parent 4cf7e6f commit 4fb610d

File tree

7 files changed

+107
-20
lines changed

7 files changed

+107
-20
lines changed

package-lock.json

Lines changed: 2 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/node/opentelemetry-instrumentation-pg/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"dependencies": {
7272
"@opentelemetry/core": "^1.26.0",
7373
"@opentelemetry/instrumentation": "^0.57.0",
74-
"@opentelemetry/semantic-conventions": "1.27.0",
74+
"@opentelemetry/semantic-conventions": "^1.27.0",
7575
"@opentelemetry/sql-common": "^0.40.1",
7676
"@types/pg": "8.6.1",
7777
"@types/pg-pool": "2.0.6"

plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {
6565
METRIC_DB_CLIENT_OPERATION_DURATION,
6666
ATTR_DB_NAMESPACE,
6767
ATTR_DB_OPERATION_NAME,
68-
} from '@opentelemetry/semantic-conventions/incubating';
68+
} from './semconv';
6969

7070
export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConfig> {
7171
private _operationDuration!: Histogram;
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation **SHOULD** use a combination of parameters that would make the name unique, for example, combining attributes `server.address`, `server.port`, and `db.namespace`, formatted as `server.address:server.port/db.namespace`. Instrumentations that generate connection pool name following different patterns **SHOULD** document it.
19+
*
20+
* @example myDataSource
21+
*
22+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
23+
*/
24+
export const ATTR_DB_CLIENT_CONNECTION_POOL_NAME =
25+
'db.client.connection.pool.name';
26+
27+
/**
28+
* The state of a connection in the pool
29+
*
30+
* @example idle
31+
*
32+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
33+
*/
34+
export const ATTR_DB_CLIENT_CONNECTION_STATE = 'db.client.connection.state';
35+
36+
/**
37+
* The name of the database, fully qualified within the server address and port.
38+
*
39+
* @example customers
40+
* @example test.users
41+
*
42+
* @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.
43+
* Semantic conventions for individual database systems **SHOULD** document what `db.namespace` means in the context of that system.
44+
* It is **RECOMMENDED** to capture the value as provided by the application without attempting to do any case normalization.
45+
* This attribute has stability level RELEASE CANDIDATE.
46+
*
47+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
48+
*/
49+
export const ATTR_DB_NAMESPACE = 'db.namespace';
50+
51+
/**
52+
* The name of the operation or command being executed.
53+
*
54+
* @example findAndModify
55+
* @example HMSET
56+
* @example SELECT
57+
*
58+
* @note It is **RECOMMENDED** to capture the value as provided by the application without attempting to do any case normalization.
59+
* If the operation name is parsed from the query text, it **SHOULD** be the first operation name found in the query.
60+
* 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.
61+
* This attribute has stability level RELEASE CANDIDATE.
62+
*
63+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
64+
*/
65+
export const ATTR_DB_OPERATION_NAME = 'db.operation.name';
66+
67+
/**
68+
* Enum value "used" for attribute {@link ATTR_DB_CLIENT_CONNECTION_STATE}.
69+
*/
70+
export const DB_CLIENT_CONNECTION_STATE_VALUE_USED = 'used';
71+
72+
/**
73+
* Enum value "idle" for attribute {@link ATTR_DB_CLIENT_CONNECTION_STATE}.
74+
*/
75+
export const DB_CLIENT_CONNECTION_STATE_VALUE_IDLE = 'idle';
76+
77+
/**
78+
* The number of connections that are currently in state described by the `state` attribute
79+
*
80+
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
81+
*/
82+
export const METRIC_DB_CLIENT_CONNECTION_COUNT = 'db.client.connection.count';
83+
84+
/**
85+
* The number of current pending requests for an open connection
86+
*
87+
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
88+
*/
89+
export const METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS =
90+
'db.client.connection.pending_requests';
91+
92+
/**
93+
* Duration of database client operations.
94+
*
95+
* @note Batch operations **SHOULD** be recorded as a single operation.
96+
*
97+
* @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
98+
*/
99+
export const METRIC_DB_CLIENT_OPERATION_DURATION =
100+
'db.client.operation.duration';

plugins/node/opentelemetry-instrumentation-pg/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
ATTR_DB_CLIENT_CONNECTION_STATE,
4343
DB_CLIENT_CONNECTION_STATE_VALUE_USED,
4444
DB_CLIENT_CONNECTION_STATE_VALUE_IDLE,
45-
} from '@opentelemetry/semantic-conventions/incubating';
45+
} from './semconv';
4646
import {
4747
PgClientExtended,
4848
PostgresCallback,

plugins/node/opentelemetry-instrumentation-pg/test/pg-pool.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import {
5555
METRIC_DB_CLIENT_CONNECTION_COUNT,
5656
METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS,
5757
METRIC_DB_CLIENT_OPERATION_DURATION,
58-
} from '@opentelemetry/semantic-conventions/incubating';
58+
} from '../src/semconv';
5959

6060
const memoryExporter = new InMemorySpanExporter();
6161

plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import {
5656
import {
5757
METRIC_DB_CLIENT_OPERATION_DURATION,
5858
ATTR_DB_OPERATION_NAME,
59-
} from '@opentelemetry/semantic-conventions/incubating';
59+
} from '../src/semconv';
6060
import { addSqlCommenterComment } from '@opentelemetry/sql-common';
6161

6262
const memoryExporter = new InMemorySpanExporter();

0 commit comments

Comments
 (0)