Skip to content

Commit 0e3fd2d

Browse files
committed
refactor(instrumentation-restify): update semconv usage to ATTR_ exports
Refs: #2377
1 parent e0858f9 commit 0e3fd2d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
isWrapped,
3232
safeExecuteInTheMiddle,
3333
} from '@opentelemetry/instrumentation';
34-
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
34+
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
3535
import { isPromise, isAsyncFunction } from './utils';
3636
import { getRPCMetadata, RPCType } from '@opentelemetry/core';
3737
import type { RestifyInstrumentationConfig } from './types';
@@ -172,7 +172,7 @@ export class RestifyInstrumentation extends InstrumentationBase<RestifyInstrumen
172172
[AttributeNames.VERSION]: this._moduleVersion || 'n/a',
173173
[AttributeNames.TYPE]: metadata.type,
174174
[AttributeNames.METHOD]: metadata.methodName,
175-
[SEMATTRS_HTTP_ROUTE]: route,
175+
[ATTR_HTTP_ROUTE]: route,
176176
};
177177
const span = this.tracer.startSpan(
178178
spanName,

plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import { context, trace, Span } from '@opentelemetry/api';
18-
import { SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions';
1918
import { RPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core';
2019
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
2120
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
@@ -495,7 +494,7 @@ describe('Restify Instrumentation', () => {
495494
describe('using requestHook in config', () => {
496495
it('calls requestHook provided function when set in config', async () => {
497496
const requestHook = (span: Span, info: RestifyRequestInfo) => {
498-
span.setAttribute(SEMATTRS_HTTP_METHOD, info.request.method);
497+
span.setAttribute('my.http.method', info.request.method);
499498
span.setAttribute('restify.layer', info.layerType);
500499
};
501500

@@ -517,7 +516,7 @@ describe('Restify Instrumentation', () => {
517516
// span from get
518517
const span = memoryExporter.getFinishedSpans()[2];
519518
assert.notStrictEqual(span, undefined);
520-
assert.strictEqual(span.attributes[SEMATTRS_HTTP_METHOD], 'GET');
519+
assert.strictEqual(span.attributes['my.http.method'], 'GET');
521520
assert.strictEqual(
522521
span.attributes['restify.layer'],
523522
'request_handler'
@@ -529,7 +528,7 @@ describe('Restify Instrumentation', () => {
529528

530529
it('does not propagate an error from a requestHook that throws exception', async () => {
531530
const requestHook = (span: Span, info: RestifyRequestInfo) => {
532-
span.setAttribute(SEMATTRS_HTTP_METHOD, info.request.method);
531+
span.setAttribute('my.http.method', info.request.method);
533532

534533
throw Error('error thrown in requestHook');
535534
};
@@ -552,7 +551,7 @@ describe('Restify Instrumentation', () => {
552551
// span from get
553552
const span = memoryExporter.getFinishedSpans()[2];
554553
assert.notStrictEqual(span, undefined);
555-
assert.strictEqual(span.attributes[SEMATTRS_HTTP_METHOD], 'GET');
554+
assert.strictEqual(span.attributes['my.http.method'], 'GET');
556555
}
557556
}
558557
);

0 commit comments

Comments
 (0)