Skip to content

Commit af9ff12

Browse files
authored
refactor(resource-detector-instana): update semconv usage to ATTR_ exports (#2857)
1 parent 24c2404 commit af9ff12

File tree

4 files changed

+72
-13
lines changed

4 files changed

+72
-13
lines changed

detectors/node/opentelemetry-resource-detector-instana/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sdk.start()
3838

3939
## Available detectors
4040

41-
This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md)
41+
This package implements Semantic Convention v1.33.1.
4242

4343
### Instana Agent Detector
4444

detectors/node/opentelemetry-resource-detector-instana/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
},
5454
"dependencies": {
5555
"@opentelemetry/core": "^2.0.0",
56-
"@opentelemetry/resources": "^2.0.0",
57-
"@opentelemetry/semantic-conventions": "^1.27.0"
56+
"@opentelemetry/resources": "^2.0.0"
5857
},
5958
"peerDependencies": {
6059
"@opentelemetry/api": "^1.3.0"

detectors/node/opentelemetry-resource-detector-instana/src/detectors/InstanaAgentDetector.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ import {
2121
DetectedResource,
2222
DetectedResourceAttributes,
2323
} from '@opentelemetry/resources';
24-
import {
25-
SEMRESATTRS_PROCESS_PID,
26-
SEMRESATTRS_SERVICE_INSTANCE_ID,
27-
} from '@opentelemetry/semantic-conventions';
24+
import { ATTR_PROCESS_PID, ATTR_SERVICE_INSTANCE_ID } from '../semconv';
2825
import * as http from 'http';
2926

3027
class InstanaAgentDetector implements ResourceDetector {
@@ -36,10 +33,7 @@ class InstanaAgentDetector implements ResourceDetector {
3633
this._gatherData()
3734
);
3835

39-
const attrNames = [
40-
SEMRESATTRS_PROCESS_PID,
41-
SEMRESATTRS_SERVICE_INSTANCE_ID,
42-
];
36+
const attrNames = [ATTR_PROCESS_PID, ATTR_SERVICE_INSTANCE_ID];
4337

4438
const attributes = {} as DetectedResourceAttributes;
4539
attrNames.forEach(name => {
@@ -61,8 +55,8 @@ class InstanaAgentDetector implements ResourceDetector {
6155
const data = await this._retryHandler(host, port, 0);
6256

6357
return {
64-
[SEMRESATTRS_PROCESS_PID]: data.pid,
65-
[SEMRESATTRS_SERVICE_INSTANCE_ID]: data.agentUuid,
58+
[ATTR_PROCESS_PID]: data.pid,
59+
[ATTR_SERVICE_INSTANCE_ID]: data.agentUuid,
6660
};
6761
} catch {
6862
return {};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
* Process identifier (PID).
25+
*
26+
* @example 1234
27+
*
28+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
29+
*/
30+
export const ATTR_PROCESS_PID = 'process.pid' as const;
31+
32+
/**
33+
* The string ID of the service instance.
34+
*
35+
* @example 627cc493-f310-47de-96bd-71410b7dec09
36+
*
37+
* @note **MUST** be unique for each instance of the same `service.namespace,service.name` pair (in other words
38+
* `service.namespace,service.name,service.instance.id` triplet **MUST** be globally unique). The ID helps to
39+
* distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled
40+
* service).
41+
*
42+
* Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC
43+
* 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of
44+
* this value if stability is desirable. In that case, the ID **SHOULD** be used as source of a UUID Version 5 and
45+
* **SHOULD** use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`.
46+
*
47+
* UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is
48+
* needed. Similar to what can be seen in the man page for the
49+
* [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/latest/machine-id.html) file, the underlying
50+
* data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it
51+
* or not via another resource attribute.
52+
*
53+
* For applications running behind an application server (like unicorn), we do not recommend using one identifier
54+
* for all processes participating in the application. Instead, it's recommended each division (e.g. a worker
55+
* thread in unicorn) to have its own instance.id.
56+
*
57+
* It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the
58+
* service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will
59+
* likely be wrong, as the Collector might not know from which container within that pod the telemetry originated.
60+
* However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance
61+
* for that telemetry. This is typically the case for scraping receivers, as they know the target address and
62+
* port.
63+
*
64+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
65+
*/
66+
export const ATTR_SERVICE_INSTANCE_ID = 'service.instance.id' as const;

0 commit comments

Comments
 (0)