Skip to content

Commit

Permalink
chore: Semantic Conventions export individual strings (#4298)
Browse files Browse the repository at this point in the history
* chore: Semantic Conventions export individual strings

* Reduce to just emit full strings and add size-limit test output to review the results

* Update generation to use createConstMap for enums where possible

* Move changelog back to Unreleased -- merge shifted it

---------

Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
MSNev and pichlermarc authored Feb 23, 2024
1 parent aff48a1 commit 5637e2a
Show file tree
Hide file tree
Showing 14 changed files with 6,695 additions and 526 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
* feat(sdk-metrics): allow single bucket histograms [#4456](https://github.com/open-telemetry/opentelemetry-js/pull/4456) @pichlermarc
* feat(instrumentation): Make `init()` method public [#4418](https://github.com/open-telemetry/opentelemetry-js/pull/4418)
* feat(context-zone-peer-dep, context-zone): support zone.js 0.13.x, 0.14.x [#4469](https://github.com/open-telemetry/opentelemetry-js/pull/4469) @pichlermarc
* chore: Semantic Conventions export individual strings [4185](https://github.com/open-telemetry/opentelemetry-js/issues/4185)

### :bug: (Bug Fix)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import { SDK_INFO } from '@opentelemetry/core';
import * as assert from 'assert';
import { IResource, Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMRESATTRS_TELEMETRY_SDK_LANGUAGE,
SEMRESATTRS_TELEMETRY_SDK_NAME,
SEMRESATTRS_TELEMETRY_SDK_VERSION,
SemanticResourceAttributes,
} from '@opentelemetry/semantic-conventions';

/**
* Test utility method to validate a cloud resource
Expand Down Expand Up @@ -199,9 +204,9 @@ export const assertTelemetrySDKResource = (
}
) => {
const defaults = {
name: SDK_INFO.NAME,
language: SDK_INFO.LANGUAGE,
version: SDK_INFO.VERSION,
name: SDK_INFO[SEMRESATTRS_TELEMETRY_SDK_NAME],
language: SDK_INFO[SEMRESATTRS_TELEMETRY_SDK_LANGUAGE],
version: SDK_INFO[SEMRESATTRS_TELEMETRY_SDK_VERSION],
};
validations = { ...defaults, ...validations };

Expand Down Expand Up @@ -317,14 +322,17 @@ const assertHasOneLabel = (prefix: string, resource: Resource): void => {

assert.ok(
hasOne,
'Resource must have one of the following attributes: ' +
'Must have one node Resource(s) starting with [' +
prefix +
'] matching the following attributes: ' +
Object.entries(SemanticResourceAttributes)
.reduce((result, [key, value]) => {
if (key.startsWith(prefix)) {
result.push(value);
}
return result;
})
.join(', ')
.join(', ') +
JSON.stringify(Object.keys(SemanticResourceAttributes))
);
};
Loading

0 comments on commit 5637e2a

Please sign in to comment.