From ecc88a38d85d5d6adf847306d96e7be77b7df8d6 Mon Sep 17 00:00:00 2001 From: Johannes Huster <66320475+JohannesHuster@users.noreply.github.com> Date: Fri, 31 May 2024 12:02:05 +0200 Subject: [PATCH] refactor(core): Use (tree-shakeable) string constants for semconv (#4739) * refactor(core): Use exported strings for semconv * Update changelog --- CHANGELOG.md | 1 + .../src/platform/browser/sdk-info.ts | 16 +++++++++------- .../src/platform/node/sdk-info.ts | 16 +++++++++------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 480036b7f4..869e21f71a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ * feat: support node 22 [#4666](https://github.com/open-telemetry/opentelemetry-js/pull/4666) @dyladan * feat(context-zone*): support zone.js 0.12.x [#4376](https://github.com/open-telemetry/opentelemetry-js/pull/4736) @maldago +* refactor(core): Use tree-shakeable string constants for semconv [#4739](https://github.com/open-telemetry/opentelemetry-js/pull/4739) @JohannesHuster ### :bug: (Bug Fix) diff --git a/packages/opentelemetry-core/src/platform/browser/sdk-info.ts b/packages/opentelemetry-core/src/platform/browser/sdk-info.ts index b804cd3c85..7d1460770d 100644 --- a/packages/opentelemetry-core/src/platform/browser/sdk-info.ts +++ b/packages/opentelemetry-core/src/platform/browser/sdk-info.ts @@ -16,15 +16,17 @@ import { VERSION } from '../../version'; import { - TelemetrySdkLanguageValues, - SemanticResourceAttributes, + SEMRESATTRS_TELEMETRY_SDK_NAME, + SEMRESATTRS_PROCESS_RUNTIME_NAME, + SEMRESATTRS_TELEMETRY_SDK_LANGUAGE, + TELEMETRYSDKLANGUAGEVALUES_WEBJS, + SEMRESATTRS_TELEMETRY_SDK_VERSION, } from '@opentelemetry/semantic-conventions'; /** Constants describing the SDK in use */ export const SDK_INFO = { - [SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', - [SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'browser', - [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: - TelemetrySdkLanguageValues.WEBJS, - [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, + [SEMRESATTRS_TELEMETRY_SDK_NAME]: 'opentelemetry', + [SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'browser', + [SEMRESATTRS_TELEMETRY_SDK_LANGUAGE]: TELEMETRYSDKLANGUAGEVALUES_WEBJS, + [SEMRESATTRS_TELEMETRY_SDK_VERSION]: VERSION, }; diff --git a/packages/opentelemetry-core/src/platform/node/sdk-info.ts b/packages/opentelemetry-core/src/platform/node/sdk-info.ts index 6c7c4c5f02..4018c23ff2 100644 --- a/packages/opentelemetry-core/src/platform/node/sdk-info.ts +++ b/packages/opentelemetry-core/src/platform/node/sdk-info.ts @@ -16,15 +16,17 @@ import { VERSION } from '../../version'; import { - TelemetrySdkLanguageValues, - SemanticResourceAttributes, + SEMRESATTRS_TELEMETRY_SDK_NAME, + SEMRESATTRS_PROCESS_RUNTIME_NAME, + SEMRESATTRS_TELEMETRY_SDK_LANGUAGE, + TELEMETRYSDKLANGUAGEVALUES_NODEJS, + SEMRESATTRS_TELEMETRY_SDK_VERSION, } from '@opentelemetry/semantic-conventions'; /** Constants describing the SDK in use */ export const SDK_INFO = { - [SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry', - [SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'node', - [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: - TelemetrySdkLanguageValues.NODEJS, - [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, + [SEMRESATTRS_TELEMETRY_SDK_NAME]: 'opentelemetry', + [SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'node', + [SEMRESATTRS_TELEMETRY_SDK_LANGUAGE]: TELEMETRYSDKLANGUAGEVALUES_NODEJS, + [SEMRESATTRS_TELEMETRY_SDK_VERSION]: VERSION, };