Skip to content

Commit

Permalink
add TELEMETRY_SDK_VERSION to profiling payloads (#854)
Browse files Browse the repository at this point in the history
* add TELEMETRY_SDK_VERSION to profiling payloads

* test for telemetry.sdk.version
  • Loading branch information
seemk authored Dec 12, 2023
1 parent bbc9a1a commit 2d8f099
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/profiling/OTLPProfilingExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = [];
Expand Down
3 changes: 3 additions & 0 deletions test/profiling/exporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2d8f099

Please sign in to comment.