diff --git a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts index c476649750..781528b73a 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -15,7 +15,7 @@ */ import { getRPCMetadata, RPCType } from '@opentelemetry/core'; -import { trace, context, diag, SpanAttributes } from '@opentelemetry/api'; +import { trace, context, diag, Attributes } from '@opentelemetry/api'; import type * as express from 'express'; import { ExpressInstrumentationConfig, ExpressRequestInfo } from './types'; import { ExpressLayerType } from './enums/ExpressLayerType'; @@ -187,7 +187,7 @@ export class ExpressInstrumentation extends InstrumentationBase< .filter(path => path !== '/' && path !== '/*') .join(''); - const attributes: SpanAttributes = { + const attributes: Attributes = { [SemanticAttributes.HTTP_ROUTE]: route.length > 0 ? route : '/', }; const metadata = getLayerMetadata(layer, layerPath); diff --git a/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts index ab53fc37e7..bae07da361 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts @@ -15,7 +15,7 @@ */ import type { Request } from 'express'; -import { SpanAttributes } from '@opentelemetry/api'; +import { Attributes } from '@opentelemetry/api'; /** * This symbol is used to mark express layer as being already instrumented @@ -67,6 +67,6 @@ export type ExpressLayer = { }; export type LayerMetadata = { - attributes: SpanAttributes; + attributes: Attributes; name: string; }; diff --git a/plugins/node/opentelemetry-instrumentation-express/src/utils.ts b/plugins/node/opentelemetry-instrumentation-express/src/utils.ts index d272434422..df9341a661 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/utils.ts @@ -14,7 +14,22 @@ * limitations under the License. */ -import { SpanAttributes } from '@opentelemetry/api'; +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Attributes } from '@opentelemetry/api'; import { IgnoreMatcher, ExpressInstrumentationConfig } from './types'; import { ExpressLayerType } from './enums/ExpressLayerType'; import { AttributeNames } from './enums/AttributeNames'; @@ -49,7 +64,7 @@ export const getLayerMetadata = ( layer: ExpressLayer, layerPath?: string ): { - attributes: SpanAttributes; + attributes: Attributes; name: string; } => { if (layer.name === 'router') {