Skip to content

Commit bc3d1b9

Browse files
authored
Merge branch 'main' into trentm-semconv-up-res-det-alibaba
2 parents 6294368 + 1acb0bb commit bc3d1b9

File tree

9 files changed

+227
-42
lines changed

9 files changed

+227
-42
lines changed

packages/instrumentation-document-load/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
"dependencies": {
7676
"@opentelemetry/core": "^2.0.0",
7777
"@opentelemetry/instrumentation": "^0.205.0",
78-
"@opentelemetry/sdk-trace-web": "^2.0.0",
79-
"@opentelemetry/semantic-conventions": "^1.27.0"
78+
"@opentelemetry/sdk-trace-web": "^2.0.0"
8079
},
8180
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-document-load#readme"
8281
}

packages/instrumentation-document-load/src/instrumentation.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ import {
4141
import { AttributeNames } from './enums/AttributeNames';
4242
/** @knipignore */
4343
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
44-
import {
45-
SEMATTRS_HTTP_URL,
46-
SEMATTRS_HTTP_USER_AGENT,
47-
} from '@opentelemetry/semantic-conventions';
44+
import { ATTR_HTTP_URL, ATTR_HTTP_USER_AGENT } from './semconv';
4845
import {
4946
addSpanPerformancePaintEvents,
5047
getPerformanceNavigationEntries,
@@ -115,7 +112,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<DocumentLoa
115112
entries
116113
);
117114
if (fetchSpan) {
118-
fetchSpan.setAttribute(SEMATTRS_HTTP_URL, location.href);
115+
fetchSpan.setAttribute(ATTR_HTTP_URL, location.href);
119116
context.with(trace.setSpan(context.active(), fetchSpan), () => {
120117
addSpanNetworkEvents(
121118
fetchSpan,
@@ -131,8 +128,8 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<DocumentLoa
131128
}
132129
});
133130

134-
rootSpan.setAttribute(SEMATTRS_HTTP_URL, location.href);
135-
rootSpan.setAttribute(SEMATTRS_HTTP_USER_AGENT, navigator.userAgent);
131+
rootSpan.setAttribute(ATTR_HTTP_URL, location.href);
132+
rootSpan.setAttribute(ATTR_HTTP_USER_AGENT, navigator.userAgent);
136133

137134
this._addResourcesSpans(rootSpan);
138135

@@ -206,7 +203,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<DocumentLoa
206203
parentSpan
207204
);
208205
if (span) {
209-
span.setAttribute(SEMATTRS_HTTP_URL, resource.name);
206+
span.setAttribute(ATTR_HTTP_URL, resource.name);
210207
addSpanNetworkEvents(
211208
span,
212209
resource,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
* This file contains a copy of unstable semantic convention definitions
19+
* used by this package.
20+
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
21+
*/
22+
23+
/**
24+
* Deprecated, use `http.response.header.content-length` instead.
25+
*
26+
* @example 3495
27+
*
28+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
29+
*
30+
* @deprecated Replaced by `http.response.header.content-length`.
31+
*/
32+
export const ATTR_HTTP_RESPONSE_CONTENT_LENGTH =
33+
'http.response_content_length' as const;
34+
35+
/**
36+
* Deprecated, use `url.full` instead.
37+
*
38+
* @example https://www.foo.bar/search?q=OpenTelemetry#SemConv
39+
*
40+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
41+
*
42+
* @deprecated Replaced by `url.full`.
43+
*/
44+
export const ATTR_HTTP_URL = 'http.url' as const;
45+
46+
/**
47+
* Deprecated, use `user_agent.original` instead.
48+
*
49+
* @example CERN-LineMode/2.15 libwww/2.17b3
50+
* @example Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1
51+
*
52+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
53+
*
54+
* @deprecated Replaced by `user_agent.original`.
55+
*/
56+
export const ATTR_HTTP_USER_AGENT = 'http.user_agent' as const;

packages/instrumentation-document-load/test/documentLoad.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ import chai from 'chai/chai.js';
4141
import * as sinon from 'sinon';
4242
import { DocumentLoadInstrumentation } from '../src';
4343
import {
44-
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH,
45-
SEMATTRS_HTTP_URL,
46-
} from '@opentelemetry/semantic-conventions';
44+
ATTR_HTTP_RESPONSE_CONTENT_LENGTH,
45+
ATTR_HTTP_URL,
46+
} from '../src/semconv';
4747
import { EventNames } from '../src/enums/EventNames';
4848

4949
const assert = chai.assert;
@@ -357,9 +357,7 @@ describe('DocumentLoad Instrumentation', () => {
357357

358358
assert.strictEqual(rootSpan.name, 'documentFetch');
359359
assert.ok(
360-
(rootSpan.attributes[
361-
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH
362-
] as number) > 0
360+
(rootSpan.attributes[ATTR_HTTP_RESPONSE_CONTENT_LENGTH] as number) > 0
363361
);
364362
assert.strictEqual(fetchSpan.name, 'documentLoad');
365363
ensureNetworkEventsExists(rsEvents);
@@ -459,11 +457,11 @@ describe('DocumentLoad Instrumentation', () => {
459457
const srEvents2 = spanResource2.events;
460458

461459
assert.strictEqual(
462-
spanResource1.attributes[SEMATTRS_HTTP_URL],
460+
spanResource1.attributes[ATTR_HTTP_URL],
463461
'http://localhost:8090/bundle.js'
464462
);
465463
assert.strictEqual(
466-
spanResource2.attributes[SEMATTRS_HTTP_URL],
464+
spanResource2.attributes[ATTR_HTTP_URL],
467465
'http://localhost:8090/sockjs-node/info?t=1572620894466'
468466
);
469467

@@ -495,7 +493,7 @@ describe('DocumentLoad Instrumentation', () => {
495493
const srEvents1 = spanResource1.events;
496494

497495
assert.strictEqual(
498-
spanResource1.attributes[SEMATTRS_HTTP_URL],
496+
spanResource1.attributes[ATTR_HTTP_URL],
499497
'http://localhost:8090/bundle.js'
500498
);
501499

@@ -847,7 +845,7 @@ describe('DocumentLoad Instrumentation', () => {
847845
) as ReadableSpan;
848846
assert.isOk(resourceSpan, 'resourceFetch span should exist');
849847
assert.exists(
850-
resourceSpan.attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH],
848+
resourceSpan.attributes[ATTR_HTTP_RESPONSE_CONTENT_LENGTH],
851849
'http.response_content_length attribute should exist'
852850
);
853851
done();

packages/instrumentation-knex/src/instrumentation.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ import {
3636
ATTR_DB_SYSTEM_NAME,
3737
ATTR_SERVER_ADDRESS,
3838
ATTR_SERVER_PORT,
39-
SEMATTRS_DB_NAME,
40-
SEMATTRS_DB_OPERATION,
41-
SEMATTRS_DB_SQL_TABLE,
42-
SEMATTRS_DB_STATEMENT,
43-
SEMATTRS_DB_SYSTEM,
44-
SEMATTRS_DB_USER,
45-
SEMATTRS_NET_PEER_NAME,
46-
SEMATTRS_NET_PEER_PORT,
47-
SEMATTRS_NET_TRANSPORT,
4839
} from '@opentelemetry/semantic-conventions';
40+
import {
41+
ATTR_DB_NAME,
42+
ATTR_DB_OPERATION,
43+
ATTR_DB_SQL_TABLE,
44+
ATTR_DB_STATEMENT,
45+
ATTR_DB_SYSTEM,
46+
ATTR_DB_USER,
47+
ATTR_NET_PEER_NAME,
48+
ATTR_NET_PEER_PORT,
49+
ATTR_NET_TRANSPORT,
50+
} from './semconv';
4951

5052
const contextSymbol = Symbol('opentelemetry.instrumentation-knex.context');
5153
const DEFAULT_CONFIG: KnexInstrumentationConfig = {
@@ -159,14 +161,14 @@ export class KnexInstrumentation extends InstrumentationBase<KnexInstrumentation
159161

160162
if (instrumentation._semconvStability & SemconvStability.OLD) {
161163
Object.assign(attributes, {
162-
[SEMATTRS_DB_SYSTEM]: utils.mapSystem(config.client),
163-
[SEMATTRS_DB_SQL_TABLE]: table,
164-
[SEMATTRS_DB_OPERATION]: operation,
165-
[SEMATTRS_DB_USER]: config?.connection?.user,
166-
[SEMATTRS_DB_NAME]: name,
167-
[SEMATTRS_NET_PEER_NAME]: config?.connection?.host,
168-
[SEMATTRS_NET_PEER_PORT]: config?.connection?.port,
169-
[SEMATTRS_NET_TRANSPORT]: transport,
164+
[ATTR_DB_SYSTEM]: utils.mapSystem(config.client),
165+
[ATTR_DB_SQL_TABLE]: table,
166+
[ATTR_DB_OPERATION]: operation,
167+
[ATTR_DB_USER]: config?.connection?.user,
168+
[ATTR_DB_NAME]: name,
169+
[ATTR_NET_PEER_NAME]: config?.connection?.host,
170+
[ATTR_NET_PEER_PORT]: config?.connection?.port,
171+
[ATTR_NET_TRANSPORT]: transport,
170172
});
171173
}
172174
if (instrumentation._semconvStability & SemconvStability.STABLE) {
@@ -186,7 +188,7 @@ export class KnexInstrumentation extends InstrumentationBase<KnexInstrumentation
186188
attributes[ATTR_DB_QUERY_TEXT] = queryText;
187189
}
188190
if (instrumentation._semconvStability & SemconvStability.OLD) {
189-
attributes[SEMATTRS_DB_STATEMENT] = queryText;
191+
attributes[ATTR_DB_STATEMENT] = queryText;
190192
}
191193
}
192194

packages/instrumentation-knex/src/semconv.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,111 @@
2020
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
2121
*/
2222

23+
/**
24+
* Deprecated, use `db.namespace` instead.
25+
*
26+
* @example customers
27+
* @example main
28+
*
29+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
30+
*
31+
* @deprecated Replaced by `db.namespace`.
32+
*/
33+
export const ATTR_DB_NAME = 'db.name' as const;
34+
35+
/**
36+
* Deprecated, use `db.operation.name` instead.
37+
*
38+
* @example findAndModify
39+
* @example HMSET
40+
* @example SELECT
41+
*
42+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
43+
*
44+
* @deprecated Replaced by `db.operation.name`.
45+
*/
46+
export const ATTR_DB_OPERATION = 'db.operation' as const;
47+
48+
/**
49+
* Deprecated, use `db.collection.name` instead.
50+
*
51+
* @example "mytable"
52+
*
53+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
54+
*
55+
* @deprecated Replaced by `db.collection.name`, but only if not extracting the value from `db.query.text`.
56+
*/
57+
export const ATTR_DB_SQL_TABLE = 'db.sql.table' as const;
58+
59+
/**
60+
* The database statement being executed.
61+
*
62+
* @example SELECT * FROM wuser_table
63+
* @example SET mykey "WuValue"
64+
*
65+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
66+
*
67+
* @deprecated Replaced by `db.query.text`.
68+
*/
69+
export const ATTR_DB_STATEMENT = 'db.statement' as const;
70+
71+
/**
72+
* Deprecated, use `db.system.name` instead.
73+
*
74+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
75+
*
76+
* @deprecated Replaced by `db.system.name`.
77+
*/
78+
export const ATTR_DB_SYSTEM = 'db.system' as const;
79+
80+
/**
81+
* Deprecated, no replacement at this time.
82+
*
83+
* @example readonly_user
84+
* @example reporting_user
85+
*
86+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
87+
*
88+
* @deprecated Removed, no replacement at this time.
89+
*/
90+
export const ATTR_DB_USER = 'db.user' as const;
91+
92+
/**
93+
* Deprecated, use `server.address` on client spans and `client.address` on server spans.
94+
*
95+
* @example example.com
96+
*
97+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
98+
*
99+
* @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.
100+
*/
101+
export const ATTR_NET_PEER_NAME = 'net.peer.name' as const;
102+
103+
/**
104+
* Deprecated, use `server.port` on client spans and `client.port` on server spans.
105+
*
106+
* @example 8080
107+
*
108+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
109+
*
110+
* @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.
111+
*/
112+
export const ATTR_NET_PEER_PORT = 'net.peer.port' as const;
113+
114+
/**
115+
* Deprecated, use `network.transport`.
116+
*
117+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
118+
*
119+
* @deprecated Replaced by `network.transport`.
120+
*/
121+
export const ATTR_NET_TRANSPORT = 'net.transport' as const;
122+
23123
/**
24124
* Enum value "sqlite" for attribute {@link ATTR_DB_SYSTEM_NAME}.
125+
*
126+
* [SQLite](https://www.sqlite.org/)
127+
*
128+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
25129
*/
26130
export const DB_SYSTEM_NAME_VALUE_SQLITE = 'sqlite' as const;

packages/resource-detector-container/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
},
5959
"dependencies": {
6060
"@opentelemetry/core": "^2.0.0",
61-
"@opentelemetry/resources": "^2.0.0",
62-
"@opentelemetry/semantic-conventions": "^1.27.0"
61+
"@opentelemetry/resources": "^2.0.0"
6362
},
6463
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/resource-detector-container#readme",
6564
"sideEffects": false

packages/resource-detector-container/src/detectors/ContainerDetector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616

1717
import { ResourceDetector, DetectedResource } from '@opentelemetry/resources';
18-
import { SEMRESATTRS_CONTAINER_ID } from '@opentelemetry/semantic-conventions';
1918

2019
import * as fs from 'fs';
2120
import * as util from 'util';
2221
import { context, diag } from '@opentelemetry/api';
2322
import { suppressTracing } from '@opentelemetry/core';
2423
import { extractContainerIdFromLine } from './utils';
24+
import { ATTR_CONTAINER_ID } from '../semconv';
2525

2626
export class ContainerDetector implements ResourceDetector {
2727
readonly CONTAINER_ID_LENGTH = 64;
@@ -39,7 +39,7 @@ export class ContainerDetector implements ResourceDetector {
3939

4040
detect(): DetectedResource {
4141
const attributes = {
42-
[SEMRESATTRS_CONTAINER_ID]: this._getContainerIdWithSuppressedTracing(),
42+
[ATTR_CONTAINER_ID]: this._getContainerIdWithSuppressedTracing(),
4343
};
4444
return { attributes };
4545
}

0 commit comments

Comments
 (0)