Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(shim-opentracing): Use tree-shakeable string constants for semconv #4746

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ 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
* refactor(shim-opentracing): Use tree-shakeable string constants for semconv [#4746](https://github.com/open-telemetry/opentelemetry-js/pull/4746) @JohannesHuster
* refactor(sdk-trace-web): Use tree-shakeable string constants for semconv [#4747](https://github.com/open-telemetry/opentelemetry-js/pull/4747) @JohannesHuster
* refactor(sdk-trace-node): Use tree-shakeable string constants for semconv [#4748](https://github.com/open-telemetry/opentelemetry-js/pull/4748) @JohannesHuster
* refactor(sdk-trace-base): Use tree-shakeable string constants for semconv [#4749](https://github.com/open-telemetry/opentelemetry-js/pull/4749) @JohannesHuster


### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down
12 changes: 8 additions & 4 deletions packages/opentelemetry-shim-opentracing/src/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import {
TextMapPropagator,
} from '@opentelemetry/api';
import * as opentracing from 'opentracing';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_EXCEPTION_MESSAGE,
SEMATTRS_EXCEPTION_STACKTRACE,
SEMATTRS_EXCEPTION_TYPE,
} from '@opentelemetry/semantic-conventions';

function translateReferences(references: opentracing.Reference[]): api.Link[] {
const links: api.Link[] = [];
Expand Down Expand Up @@ -325,15 +329,15 @@ export class SpanShim extends opentracing.Span {
for (const [k, v] of entries) {
switch (k) {
case 'error.kind': {
mappedAttributes[SemanticAttributes.EXCEPTION_TYPE] = v;
mappedAttributes[SEMATTRS_EXCEPTION_TYPE] = v;
break;
}
case 'message': {
mappedAttributes[SemanticAttributes.EXCEPTION_MESSAGE] = v;
mappedAttributes[SEMATTRS_EXCEPTION_MESSAGE] = v;
break;
}
case 'stack': {
mappedAttributes[SemanticAttributes.EXCEPTION_STACKTRACE] = v;
mappedAttributes[SEMATTRS_EXCEPTION_STACKTRACE] = v;
break;
}
default: {
Expand Down
22 changes: 13 additions & 9 deletions packages/opentelemetry-shim-opentracing/test/Shim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ import {
import { performance } from 'perf_hooks';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { JaegerPropagator } from '@opentelemetry/propagator-jaeger';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_EXCEPTION_MESSAGE,
SEMATTRS_EXCEPTION_STACKTRACE,
SEMATTRS_EXCEPTION_TYPE,
} from '@opentelemetry/semantic-conventions';

describe('OpenTracing Shim', () => {
const compositePropagator = new CompositePropagator({
Expand Down Expand Up @@ -378,7 +382,7 @@ describe('OpenTracing Shim', () => {
span.logEvent('error', payload);
assert.strictEqual(otSpan.events[0].name, 'exception');
const expectedAttributes = {
[SemanticAttributes.EXCEPTION_MESSAGE]: 'boom',
[SEMATTRS_EXCEPTION_MESSAGE]: 'boom',
};
assert.deepStrictEqual(
otSpan.events[0].attributes,
Expand All @@ -397,9 +401,9 @@ describe('OpenTracing Shim', () => {
assert.strictEqual(otSpan.events[0].name, 'exception');
const expectedAttributes = {
fault: 'meow',
[SemanticAttributes.EXCEPTION_TYPE]: 'boom',
[SemanticAttributes.EXCEPTION_MESSAGE]: 'oh no!',
[SemanticAttributes.EXCEPTION_STACKTRACE]: 'pancakes',
[SEMATTRS_EXCEPTION_TYPE]: 'boom',
[SEMATTRS_EXCEPTION_MESSAGE]: 'oh no!',
[SEMATTRS_EXCEPTION_STACKTRACE]: 'pancakes',
};
assert.deepStrictEqual(
otSpan.events[0].attributes,
Expand Down Expand Up @@ -446,7 +450,7 @@ describe('OpenTracing Shim', () => {
Math.trunc(tomorrow / 1000)
);
const expectedAttributes = {
[SemanticAttributes.EXCEPTION_MESSAGE]: 'boom',
[SEMATTRS_EXCEPTION_MESSAGE]: 'boom',
};
assert.deepStrictEqual(
otSpan.events[0].attributes,
Expand All @@ -471,9 +475,9 @@ describe('OpenTracing Shim', () => {
const expectedAttributes = {
event: 'error',
fault: 'meow',
[SemanticAttributes.EXCEPTION_TYPE]: 'boom',
[SemanticAttributes.EXCEPTION_MESSAGE]: 'oh no!',
[SemanticAttributes.EXCEPTION_STACKTRACE]: 'pancakes',
[SEMATTRS_EXCEPTION_TYPE]: 'boom',
[SEMATTRS_EXCEPTION_MESSAGE]: 'oh no!',
[SEMATTRS_EXCEPTION_STACKTRACE]: 'pancakes',
};
assert.deepStrictEqual(
otSpan.events[0].attributes,
Expand Down
Loading