Skip to content

Commit 2e639c2

Browse files
authored
chore(instrumentation-oracledb): update semconv constants to match experimental values (#3106)
Closes: #3083
1 parent 39c03d9 commit 2e639c2

File tree

6 files changed

+81
-126
lines changed

6 files changed

+81
-126
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/instrumentation-oracledb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
},
7575
"dependencies": {
7676
"@opentelemetry/instrumentation": "^0.206.0",
77-
"@opentelemetry/semantic-conventions": "^1.27.0",
77+
"@opentelemetry/semantic-conventions": "^1.34.0",
7878
"@types/oracledb": "6.5.2"
7979
},
8080
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-oracledb#readme"

packages/instrumentation-oracledb/src/OracleTelemetryTraceHandler.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ import {
2626
diag,
2727
} from '@opentelemetry/api';
2828
import {
29+
ATTR_DB_NAMESPACE,
30+
ATTR_DB_QUERY_TEXT,
31+
ATTR_DB_SYSTEM_NAME,
32+
ATTR_DB_OPERATION_NAME,
2933
ATTR_SERVER_PORT,
3034
ATTR_SERVER_ADDRESS,
3135
ATTR_NETWORK_TRANSPORT,
3236
} from '@opentelemetry/semantic-conventions';
3337
import {
34-
ATTR_DB_SYSTEM,
35-
ATTR_DB_NAMESPACE,
36-
ATTR_DB_OPERATION_NAME,
37-
ATTR_DB_STATEMENT,
38-
ATTR_DB_OPERATION_PARAMETER,
3938
ATTR_DB_USER,
39+
ATTR_DB_OPERATION_PARAMETER,
40+
DB_SYSTEM_NAME_VALUE_ORACLE_DB,
4041
} from './semconv';
4142

4243
import type * as oracleDBTypes from 'oracledb';
@@ -46,7 +47,7 @@ const OUT_BIND = 3003; // bindinfo direction value.
4647
// Local modules.
4748
import { OracleInstrumentationConfig, SpanConnectionConfig } from './types';
4849
import { TraceSpanData, SpanCallLevelConfig } from './internal-types';
49-
import { SpanNames, DB_SYSTEM_VALUE_ORACLE } from './constants';
50+
import { SpanNames } from './constants';
5051

5152
// It dynamically retrieves the TraceHandlerBase class from the oracledb module
5253
// (if available) while avoiding direct imports that could cause issues if
@@ -111,7 +112,7 @@ export function getOracleTelemetryTraceHandlerClass(
111112
// semantic standards and module custom keys.
112113
private _getConnectionSpanAttributes(config: SpanConnectionConfig) {
113114
return {
114-
[ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_ORACLE,
115+
[ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_ORACLE_DB,
115116
[ATTR_NETWORK_TRANSPORT]: config.protocol,
116117
[ATTR_DB_USER]: config.user,
117118
[ATTR_DB_NAMESPACE]: this._getDBNameSpace(
@@ -147,16 +148,16 @@ export function getOracleTelemetryTraceHandlerClass(
147148
if (Array.isArray(values)) {
148149
// Handle indexed (positional) parameters
149150
values.forEach((value, index) => {
150-
const key = `${ATTR_DB_OPERATION_PARAMETER}.${index}`;
151151
const extractedValue = this._extractValue(value);
152152
if (extractedValue !== undefined) {
153-
convertedValues[key] = extractedValue;
153+
convertedValues[ATTR_DB_OPERATION_PARAMETER(`${index}`)] =
154+
extractedValue;
154155
}
155156
});
156157
} else if (values && typeof values === 'object') {
157158
// Handle named parameters
158159
for (const [paramName, value] of Object.entries(values)) {
159-
const key = `${ATTR_DB_OPERATION_PARAMETER}.${paramName}`;
160+
const key = ATTR_DB_OPERATION_PARAMETER(paramName);
160161
let inVal: any = value;
161162

162163
if (inVal && typeof inVal === 'object') {
@@ -216,7 +217,7 @@ export function getOracleTelemetryTraceHandlerClass(
216217
this._instrumentConfig.dbStatementDump ||
217218
this._instrumentConfig.enhancedDatabaseReporting
218219
) {
219-
span.setAttribute(ATTR_DB_STATEMENT, callConfig.statement);
220+
span.setAttribute(ATTR_DB_QUERY_TEXT, callConfig.statement);
220221
if (this._instrumentConfig.enhancedDatabaseReporting && !roundTrip) {
221222
const values = this._getValues(callConfig.values);
222223
if (values) {

packages/instrumentation-oracledb/src/constants.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,3 @@ export enum SpanNames {
3838
LOB_MESSAGE = 'oracledb.LobOpMessage',
3939
LOB_GETDATA = 'oracledb.Lob.getData',
4040
}
41-
42-
/*
43-
* The semantic conventions defined DBSYSTEMVALUES_ORACLE as oracle, hence
44-
* defining the new constant to explicitly mention db.
45-
*
46-
*/
47-
export const DB_SYSTEM_VALUE_ORACLE = 'oracle.db';

packages/instrumentation-oracledb/src/semconv.ts

Lines changed: 23 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,86 +16,46 @@
1616
* Copyright (c) 2025, Oracle and/or its affiliates.
1717
* */
1818

19-
/**
20-
* The database management system (DBMS) product as identified
21-
* by the client instrumentation.
22-
*
19+
/*
20+
* This file contains a copy of unstable semantic convention definitions
21+
* used by this package.
22+
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
2323
*/
24-
export const ATTR_DB_SYSTEM = 'db.system.name';
2524

2625
/**
27-
* The database associated with the connection, qualified by the instance name, database name and service name.
26+
* A database operation parameter, with `<key>` being the parameter name, and the attribute value being a string representation of the parameter value.
2827
*
29-
* @example ORCL1|PDB1|db_high.adb.oraclecloud.com
30-
* @example ORCL1|DB1|db_low.adb.oraclecloud.com
31-
*
32-
* @note It **SHOULD** be set to the combination of instance name, database name and
33-
* service name following the `{instance_name}|{database_name}|{service_name}` pattern.
34-
* For CDB architecture, database name would be pdb name. For Non-CDB, it would be
35-
* **DB_NAME** parameter.
36-
* This attribute has stability level RELEASE CANDIDATE.
37-
*
38-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
39-
*/
40-
export const ATTR_DB_NAMESPACE = 'db.namespace';
41-
42-
/**
43-
* The name of the operation or command being executed.
28+
* @example someval
29+
* @example 55
4430
*
45-
* @example INSERT
46-
* @example COMMIT
47-
* @example SELECT
31+
* @note For example, a client-side maximum number of rows to read from the database
32+
* **MAY** be recorded as the `db.operation.parameter.max_rows` attribute.
4833
*
49-
* @note It is **RECOMMENDED** to capture the value as provided by the application without attempting to do any case normalization.
50-
* If the operation name is parsed from the query text, it **SHOULD** be the first operation name found in the query.
51-
* 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.
52-
* This attribute has stability level RELEASE CANDIDATE.
34+
* `db.query.text` parameters **SHOULD** be captured using `db.query.parameter.<key>`
35+
* instead of `db.operation.parameter.<key>`.
5336
*
5437
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
5538
*/
56-
export const ATTR_DB_OPERATION_NAME = 'db.operation.name';
39+
export const ATTR_DB_OPERATION_PARAMETER = (key: string) =>
40+
`db.operation.parameter.${key}`;
5741

5842
/**
59-
* The database query being executed.
60-
*
61-
* @example SELECT * FROM wuser_table where username = :1 // bind by position
62-
* @example SELECT * FROM wuser_table where username = :name // bind by name
63-
* @example SELECT * FROM wuser_table where username = 'John' // literals
43+
* Deprecated, no replacement at this time.
6444
*
65-
* @note For sanitization see [Sanitization of `db.query.text`](../database/database-spans.md#sanitization-of-dbquerytext).
66-
* For batch operations, if the individual operations are known to have the same query text then
67-
* that query text **SHOULD** be used, otherwise all of the individual query texts **SHOULD**
68-
* be concatenated with separator `; ` or some other database system specific separator if more applicable.
69-
*
70-
* Non-parameterized or Parameterized query text **SHOULD NOT** be collected by default unless
71-
* explicitly configured and sanitized to exclude sensitive data, e.g. by redacting all
72-
* literal values present in the query text. See Sanitization of `db.query.text`.
73-
*
74-
* Parameterized query text MUST also NOT be collected by default unless explicitly configured.
75-
* The query parameter values themselves are opt-in, see [`db.operation.parameter.<key>`](../attributes-registry/db.md))
45+
* @example readonly_user
46+
* @example reporting_user
7647
*
7748
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
78-
*/
79-
export const ATTR_DB_STATEMENT = 'db.query.text';
80-
81-
/**
82-
* A database operation parameter, with <key> being the parameter name,
83-
* and the attribute value being a string representation of the parameter value.
8449
*
85-
* @example someval
86-
* @example 55
87-
*
88-
* @note If a parameter has no name and instead is referenced only by index, then
89-
* <key> **SHOULD** be the 0-based index. If `db.query.text` is also captured, then
90-
* `db.operation.parameter.<key>` **SHOULD** match up with the parameterized placeholders
91-
* present in db.query.text
92-
*
93-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
50+
* @deprecated Removed, no replacement at this time.
9451
*/
95-
export const ATTR_DB_OPERATION_PARAMETER = 'db.operation.parameter';
52+
export const ATTR_DB_USER = 'db.user' as const;
9653

9754
/**
98-
* Username for accessing the database.
55+
* Enum value "oracle.db" for attribute {@link ATTR_DB_SYSTEM_NAME}.
56+
*
57+
* [Oracle Database](https://www.oracle.com/database/)
9958
*
59+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
10060
*/
101-
export const ATTR_DB_USER = 'db.user';
61+
export const DB_SYSTEM_NAME_VALUE_ORACLE_DB = 'oracle.db' as const;

0 commit comments

Comments
 (0)