Skip to content

Commit

Permalink
use exported strings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieDanielson committed Mar 22, 2024
1 parent f5742c9 commit f21b8b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
InMemorySpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import { RPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core';
import { ExpressLayerType } from '../src/enums/ExpressLayerType';
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('ExpressInstrumentation', () => {
.find(span => span.name.includes('request handler'));
assert.notStrictEqual(requestHandlerSpan, undefined);
assert.strictEqual(
requestHandlerSpan?.attributes[SemanticAttributes.HTTP_ROUTE],
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
'/mw'
);

Expand Down Expand Up @@ -196,7 +196,7 @@ describe('ExpressInstrumentation', () => {
.find(span => span.name.includes('request handler'));
assert.notStrictEqual(requestHandlerSpan, undefined);
assert.strictEqual(
requestHandlerSpan?.attributes[SemanticAttributes.HTTP_ROUTE],
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
'/'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as assert from 'assert';
import { AttributeNames } from '../src/enums/AttributeNames';
import { ExpressInstrumentation } from '../src';
import { createServer, httpRequest, serverWithMiddleware } from './utils';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
import * as testUtils from '@opentelemetry/contrib-test-utils';

const instrumentation = new ExpressInstrumentation();
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('ExpressInstrumentation', () => {
.find(span => span.name.includes('request handler'));
assert.notStrictEqual(requestHandlerSpan, undefined);
assert.strictEqual(
requestHandlerSpan?.attributes[SemanticAttributes.HTTP_ROUTE],
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
'/toto/:id'
);
assert.strictEqual(
Expand Down Expand Up @@ -481,7 +481,7 @@ describe('ExpressInstrumentation', () => {
.getFinishedSpans()
.find(span => span.name.includes('request handler'));
assert.strictEqual(
requestHandlerSpan?.attributes[SemanticAttributes.HTTP_ROUTE],
requestHandlerSpan?.attributes[SEMATTRS_HTTP_ROUTE],
'/double-slashes/:id'
);
assert.strictEqual(rpcMetadata?.route, '/double-slashes/:id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import * as sinon from 'sinon';
import { ExpressInstrumentation } from '../src';
import { ExpressRequestInfo, SpanNameHook } from '../src/types';
import { ExpressLayerType } from '../src/enums/ExpressLayerType';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions';

const instrumentation = new ExpressInstrumentation();
instrumentation.enable();
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('ExpressInstrumentation hooks', () => {

it('should call requestHook when set in config', async () => {
const requestHook = sinon.spy((span: Span, info: ExpressRequestInfo) => {
span.setAttribute(SemanticAttributes.HTTP_METHOD, info.request.method);
span.setAttribute(SEMATTRS_HTTP_METHOD, info.request.method);

if (info.layerType) {
span.setAttribute('express.layer_type', info.layerType);
Expand Down

0 comments on commit f21b8b0

Please sign in to comment.