From 2d8f099becf3f7c33eb93efa173633fe64ce8f51 Mon Sep 17 00:00:00 2001 From: Siim Kallas Date: Tue, 12 Dec 2023 20:16:49 +0200 Subject: [PATCH] add TELEMETRY_SDK_VERSION to profiling payloads (#854) * add TELEMETRY_SDK_VERSION to profiling payloads * test for telemetry.sdk.version --- src/profiling/OTLPProfilingExporter.ts | 2 ++ test/profiling/exporter.test.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/profiling/OTLPProfilingExporter.ts b/src/profiling/OTLPProfilingExporter.ts index d2771d21..f9d87f4f 100644 --- a/src/profiling/OTLPProfilingExporter.ts +++ b/src/profiling/OTLPProfilingExporter.ts @@ -19,6 +19,7 @@ import * as path from 'path'; import { CpuProfile, HeapProfile, ProfilingExporter } from './types'; import { diag } from '@opentelemetry/api'; import { Resource } from '@opentelemetry/resources'; +import { VERSION } from '@opentelemetry/core'; import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { parseEndpoint, @@ -104,6 +105,7 @@ export class OTLPProfilingExporter implements ProfilingExporter { const resource = new Resource({ [SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: 'node', + [SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION, }).merge(options.resource); this._resourceAttributes = []; diff --git a/test/profiling/exporter.test.ts b/test/profiling/exporter.test.ts index cf722d2d..335d536d 100644 --- a/test/profiling/exporter.test.ts +++ b/test/profiling/exporter.test.ts @@ -18,6 +18,7 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; import { OTLPProfilingExporter } from '../../src/profiling/OTLPProfilingExporter'; import { Resource } from '@opentelemetry/resources'; +import { VERSION } from '@opentelemetry/core'; import * as utils from '../utils'; import * as grpc from '@grpc/grpc-js'; import { cpuProfile, heapProfile } from './profiles'; @@ -85,6 +86,7 @@ describe('profiling OTLP exporter', () => { const { instrumentationLibraryLogs, resource } = resourceLogs[0]; assert.deepStrictEqual(resource.attributes, [ { key: 'telemetry.sdk.language', value: { stringValue: 'node' } }, + { key: 'telemetry.sdk.version', value: { stringValue: VERSION } }, { key: 'service', value: { stringValue: 'foo' } }, ]); assert.deepStrictEqual(instrumentationLibraryLogs.length, 1); @@ -124,6 +126,7 @@ describe('profiling OTLP exporter', () => { const { instrumentationLibraryLogs, resource } = resourceLogs[0]; assert.deepStrictEqual(resource.attributes, [ { key: 'telemetry.sdk.language', value: { stringValue: 'node' } }, + { key: 'telemetry.sdk.version', value: { stringValue: VERSION } }, { key: 'service', value: { stringValue: 'foo' } }, ]); assert.deepStrictEqual(instrumentationLibraryLogs.length, 1);