Skip to content

Commit b417e90

Browse files
authored
refactor(instrumentation-express): update semconv usage to ATTR_ exports (#2859)
1 parent 65a1389 commit b417e90

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
isWrapped,
4242
safeExecuteInTheMiddle,
4343
} from '@opentelemetry/instrumentation';
44-
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
44+
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
4545
import {
4646
ExpressLayer,
4747
ExpressRouter,
@@ -195,7 +195,7 @@ export class ExpressInstrumentation extends InstrumentationBase<ExpressInstrumen
195195
.replace(/\/{2,}/g, '/');
196196

197197
const attributes: Attributes = {
198-
[SEMATTRS_HTTP_ROUTE]: route.length > 0 ? route : '/',
198+
[ATTR_HTTP_ROUTE]: route.length > 0 ? route : '/',
199199
};
200200
const metadata = getLayerMetadata(route, layer, layerPath);
201201
const type = metadata.attributes[

plugins/node/opentelemetry-instrumentation-express/test/custom-config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
InMemorySpanExporter,
2222
SimpleSpanProcessor,
2323
} from '@opentelemetry/sdk-trace-base';
24-
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
24+
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
2525
import * as assert from 'assert';
2626
import { RPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core';
2727
import { ExpressLayerType } from '../src/enums/ExpressLayerType';
@@ -145,7 +145,7 @@ describe('ExpressInstrumentation', () => {
145145
.find(span => span.name.includes('request handler'));
146146
assert.notStrictEqual(requestHandlerSpan, undefined);
147147
assert.strictEqual(
148-
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
148+
requestHandlerSpan?.attributes[ATTR_HTTP_ROUTE],
149149
'/mw'
150150
);
151151

@@ -196,7 +196,7 @@ describe('ExpressInstrumentation', () => {
196196
.find(span => span.name.includes('request handler'));
197197
assert.notStrictEqual(requestHandlerSpan, undefined);
198198
assert.strictEqual(
199-
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
199+
requestHandlerSpan?.attributes[ATTR_HTTP_ROUTE],
200200
'/'
201201
);
202202

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as semver from 'semver';
2626
import { AttributeNames } from '../src/enums/AttributeNames';
2727
import { ExpressInstrumentation } from '../src';
2828
import { createServer, httpRequest, serverWithMiddleware } from './utils';
29-
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
29+
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
3030
import * as testUtils from '@opentelemetry/contrib-test-utils';
3131

3232
const instrumentation = new ExpressInstrumentation();
@@ -119,7 +119,7 @@ describe('ExpressInstrumentation', () => {
119119
.find(span => span.name.includes('request handler'));
120120
assert.notStrictEqual(requestHandlerSpan, undefined);
121121
assert.strictEqual(
122-
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
122+
requestHandlerSpan?.attributes[ATTR_HTTP_ROUTE],
123123
'/toto/:id'
124124
);
125125
assert.strictEqual(
@@ -486,7 +486,7 @@ describe('ExpressInstrumentation', () => {
486486
.getFinishedSpans()
487487
.find(span => span.name.includes('request handler'));
488488
assert.strictEqual(
489-
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
489+
requestHandlerSpan?.attributes[ATTR_HTTP_ROUTE],
490490
'/double-slashes/:id'
491491
);
492492
assert.strictEqual(rpcMetadata?.route, '/double-slashes/:id');

plugins/node/opentelemetry-instrumentation-express/test/hooks.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import * as sinon from 'sinon';
2727
import { ExpressInstrumentation } from '../src';
2828
import { ExpressRequestInfo, SpanNameHook } from '../src/types';
2929
import { ExpressLayerType } from '../src/enums/ExpressLayerType';
30-
import { SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions';
30+
import { ATTR_HTTP_REQUEST_METHOD } from '@opentelemetry/semantic-conventions';
3131

3232
const instrumentation = new ExpressInstrumentation();
3333
instrumentation.enable();
@@ -179,7 +179,7 @@ describe('ExpressInstrumentation hooks', () => {
179179

180180
it('should call requestHook when set in config', async () => {
181181
const requestHook = sinon.spy((span: Span, info: ExpressRequestInfo) => {
182-
span.setAttribute(SEMATTRS_HTTP_METHOD, info.request.method);
182+
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, info.request.method);
183183

184184
if (info.layerType) {
185185
span.setAttribute('express.layer_type', info.layerType);
@@ -204,7 +204,7 @@ describe('ExpressInstrumentation hooks', () => {
204204
assert.strictEqual(spans.length, 2);
205205
sinon.assert.calledOnce(requestHook);
206206
assert.strictEqual(
207-
requestHandlerSpan?.attributes['http.method'],
207+
requestHandlerSpan?.attributes['http.request.method'],
208208
'GET'
209209
);
210210
assert.strictEqual(

0 commit comments

Comments
 (0)