diff --git a/packages/node/package.json b/packages/node/package.json index ab37ba76cec9..be62b7f59db7 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -53,9 +53,9 @@ "access": "public" }, "dependencies": { - "@opentelemetry/api": "1.7.0", - "@opentelemetry/context-async-hooks": "1.21.0", - "@opentelemetry/core": "1.21.0", + "@opentelemetry/api": "^1.8.0", + "@opentelemetry/context-async-hooks": "^1.23.0", + "@opentelemetry/core": "^1.23.0", "@opentelemetry/instrumentation": "0.48.0", "@opentelemetry/instrumentation-express": "0.35.0", "@opentelemetry/instrumentation-fastify": "0.33.0", @@ -69,9 +69,9 @@ "@opentelemetry/instrumentation-mysql2": "0.35.0", "@opentelemetry/instrumentation-nestjs-core": "0.34.0", "@opentelemetry/instrumentation-pg": "0.38.0", - "@opentelemetry/resources": "1.21.0", - "@opentelemetry/sdk-trace-base": "1.21.0", - "@opentelemetry/semantic-conventions": "1.21.0", + "@opentelemetry/resources": "^1.23.0", + "@opentelemetry/sdk-trace-base": "^1.23.0", + "@opentelemetry/semantic-conventions": "^1.23.0", "@prisma/instrumentation": "5.9.0", "@sentry/core": "8.0.0-beta.1", "@sentry/opentelemetry": "8.0.0-beta.1", diff --git a/packages/node/src/integrations/tracing/koa.ts b/packages/node/src/integrations/tracing/koa.ts index 938e815e2b2f..7ebb9de48d15 100644 --- a/packages/node/src/integrations/tracing/koa.ts +++ b/packages/node/src/integrations/tracing/koa.ts @@ -1,6 +1,6 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { KoaInstrumentation } from '@opentelemetry/instrumentation-koa'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; import { captureException, defineIntegration, @@ -26,7 +26,7 @@ const _koaIntegration = (() => { return; } const attributes = spanToJSON(span).data; - const route = attributes && attributes[SemanticAttributes.HTTP_ROUTE]; + const route = attributes && attributes[SEMATTRS_HTTP_ROUTE]; const method = info.context.request.method.toUpperCase() || 'GET'; if (route) { getIsolationScope().setTransactionName(`${method} ${route}`); diff --git a/packages/node/src/sdk/initOtel.ts b/packages/node/src/sdk/initOtel.ts index 62473969f7d4..f27635610c9c 100644 --- a/packages/node/src/sdk/initOtel.ts +++ b/packages/node/src/sdk/initOtel.ts @@ -1,7 +1,11 @@ import { DiagLogLevel, diag } from '@opentelemetry/api'; import { Resource } from '@opentelemetry/resources'; import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base'; -import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMRESATTRS_SERVICE_NAME, + SEMRESATTRS_SERVICE_NAMESPACE, + SEMRESATTRS_SERVICE_VERSION, +} from '@opentelemetry/semantic-conventions'; import { SDK_VERSION } from '@sentry/core'; import { SentryPropagator, SentrySampler, SentrySpanProcessor, setupEventContextTrace } from '@sentry/opentelemetry'; import { logger } from '@sentry/utils'; @@ -36,9 +40,9 @@ export function setupOtel(client: NodeClient): BasicTracerProvider { const provider = new BasicTracerProvider({ sampler: new SentrySampler(client), resource: new Resource({ - [SemanticResourceAttributes.SERVICE_NAME]: 'node', - [SemanticResourceAttributes.SERVICE_NAMESPACE]: 'sentry', - [SemanticResourceAttributes.SERVICE_VERSION]: SDK_VERSION, + [SEMRESATTRS_SERVICE_NAME]: 'node', + [SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry', + [SEMRESATTRS_SERVICE_VERSION]: SDK_VERSION, }), forceFlushTimeoutMillis: 500, }); diff --git a/packages/opentelemetry/package.json b/packages/opentelemetry/package.json index 3c8e7a4ced31..1d0f01d2875f 100644 --- a/packages/opentelemetry/package.json +++ b/packages/opentelemetry/package.json @@ -47,18 +47,17 @@ "@sentry/utils": "8.0.0-beta.1" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.0", - "@opentelemetry/core": "^1.0.0", - "@opentelemetry/sdk-trace-base": "^1.0.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/api": "^1.8.0", + "@opentelemetry/core": "^1.23.0", + "@opentelemetry/sdk-trace-base": "^1.23.0", + "@opentelemetry/semantic-conventions": "^1.23.0" }, "devDependencies": { - "@opentelemetry/api": "^1.6.0", - "@opentelemetry/context-async-hooks": "^1.17.1", - "@opentelemetry/core": "^1.17.1", - "@opentelemetry/sdk-trace-base": "^1.17.1", - "@opentelemetry/sdk-trace-node": "^1.17.1", - "@opentelemetry/semantic-conventions": "^1.17.1" + "@opentelemetry/api": "^1.8.0", + "@opentelemetry/context-async-hooks": "^1.23.0", + "@opentelemetry/core": "^1.23.0", + "@opentelemetry/sdk-trace-base": "^1.23.0", + "@opentelemetry/semantic-conventions": "^1.23.0" }, "scripts": { "build": "run-p build:transpile build:types", diff --git a/packages/opentelemetry/src/propagator.ts b/packages/opentelemetry/src/propagator.ts index 6640a0f4e0f1..45dcf811eaa8 100644 --- a/packages/opentelemetry/src/propagator.ts +++ b/packages/opentelemetry/src/propagator.ts @@ -2,7 +2,7 @@ import type { Baggage, Context, Span, SpanContext, TextMapGetter, TextMapSetter import { context } from '@opentelemetry/api'; import { TraceFlags, propagation, trace } from '@opentelemetry/api'; import { TraceState, W3CBaggagePropagator, isTracingSuppressed } from '@opentelemetry/core'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_URL } from '@opentelemetry/semantic-conventions'; import type { continueTrace } from '@sentry/core'; import { hasTracingEnabled } from '@sentry/core'; import { getRootSpan } from '@sentry/core'; @@ -329,7 +329,7 @@ function getExistingBaggage(carrier: unknown): string | undefined { * 2. Else, if the active span has no URL attribute (e.g. it is unsampled), we check a special trace state (which we set in our sampler). */ function getCurrentURL(span: Span): string | undefined { - const urlAttribute = spanToJSON(span).data?.[SemanticAttributes.HTTP_URL]; + const urlAttribute = spanToJSON(span).data?.[SEMATTRS_HTTP_URL]; if (urlAttribute) { return urlAttribute; } diff --git a/packages/opentelemetry/src/sampler.ts b/packages/opentelemetry/src/sampler.ts index 17490686b5bd..10be97b0a4bd 100644 --- a/packages/opentelemetry/src/sampler.ts +++ b/packages/opentelemetry/src/sampler.ts @@ -9,7 +9,7 @@ import type { Client, SpanAttributes } from '@sentry/types'; import { logger } from '@sentry/utils'; import { SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, SENTRY_TRACE_STATE_URL } from './constants'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_URL } from '@opentelemetry/semantic-conventions'; import { DEBUG_BUILD } from './debug-build'; import { getPropagationContextFromSpan } from './propagator'; import { getSamplingDecision } from './utils/getSamplingDecision'; @@ -43,7 +43,7 @@ export class SentrySampler implements Sampler { let traceState = parentContext?.traceState || new TraceState(); // We always keep the URL on the trace state, so we can access it in the propagator - const url = spanAttributes[SemanticAttributes.HTTP_URL]; + const url = spanAttributes[SEMATTRS_HTTP_URL]; if (url && typeof url === 'string') { traceState = traceState.set(SENTRY_TRACE_STATE_URL, url); } @@ -56,7 +56,7 @@ export class SentrySampler implements Sampler { // but we want to leave downstream sampling decisions up to the server if ( spanKind === SpanKind.CLIENT && - spanAttributes[SemanticAttributes.HTTP_METHOD] && + spanAttributes[SEMATTRS_HTTP_METHOD] && (!parentSpan || parentContext?.isRemote) ) { return { decision: SamplingDecision.NOT_RECORD, traceState }; @@ -86,7 +86,7 @@ export class SentrySampler implements Sampler { [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: sampleRate, }; - const method = `${spanAttributes[SemanticAttributes.HTTP_METHOD]}`.toUpperCase(); + const method = `${spanAttributes[SEMATTRS_HTTP_METHOD]}`.toUpperCase(); if (method === 'OPTIONS' || method === 'HEAD') { DEBUG_BUILD && logger.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`); return { diff --git a/packages/opentelemetry/src/spanExporter.ts b/packages/opentelemetry/src/spanExporter.ts index 3ff88742db64..abf82ba8a3f0 100644 --- a/packages/opentelemetry/src/spanExporter.ts +++ b/packages/opentelemetry/src/spanExporter.ts @@ -1,7 +1,7 @@ import type { Span } from '@opentelemetry/api'; import { SpanKind } from '@opentelemetry/api'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_STATUS_CODE } from '@opentelemetry/semantic-conventions'; import { captureEvent, getCapturedScopesOnSpan, @@ -335,8 +335,8 @@ function getData(span: ReadableSpan): Record { 'otel.kind': SpanKind[span.kind], }; - if (attributes[SemanticAttributes.HTTP_STATUS_CODE]) { - const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] as string; + if (attributes[SEMATTRS_HTTP_STATUS_CODE]) { + const statusCode = attributes[SEMATTRS_HTTP_STATUS_CODE] as string; data['http.response.status_code'] = statusCode; } diff --git a/packages/opentelemetry/src/utils/getRequestSpanData.ts b/packages/opentelemetry/src/utils/getRequestSpanData.ts index 0154f8e4cd3e..8ce4419c925d 100644 --- a/packages/opentelemetry/src/utils/getRequestSpanData.ts +++ b/packages/opentelemetry/src/utils/getRequestSpanData.ts @@ -1,6 +1,6 @@ import type { Span } from '@opentelemetry/api'; import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_URL } from '@opentelemetry/semantic-conventions'; import type { SanitizedRequestData } from '@sentry/types'; import { getSanitizedUrlString, parseUrl } from '@sentry/utils'; @@ -16,8 +16,8 @@ export function getRequestSpanData(span: Span | ReadableSpan): Partial = { - url: span.attributes[SemanticAttributes.HTTP_URL] as string | undefined, - 'http.method': span.attributes[SemanticAttributes.HTTP_METHOD] as string | undefined, + url: span.attributes[SEMATTRS_HTTP_URL] as string | undefined, + 'http.method': span.attributes[SEMATTRS_HTTP_METHOD] as string | undefined, }; // Default to GET if URL is set but method is not @@ -26,7 +26,7 @@ export function getRequestSpanData(span: Span | ReadableSpan): Partial'; // if http.method exists, this is an http request span - const httpMethod = attributes[SemanticAttributes.HTTP_METHOD]; + const httpMethod = attributes[SEMATTRS_HTTP_METHOD]; if (httpMethod) { return descriptionForHttpMethod({ attributes, name, kind: getSpanKind(span) }, httpMethod); } // If db.type exists then this is a database call span. - const dbSystem = attributes[SemanticAttributes.DB_SYSTEM]; + const dbSystem = attributes[SEMATTRS_DB_SYSTEM]; if (dbSystem) { return descriptionForDbSystem({ attributes, name }); } // If rpc.service exists then this is a rpc call span. - const rpcService = attributes[SemanticAttributes.RPC_SERVICE]; + const rpcService = attributes[SEMATTRS_RPC_SERVICE]; if (rpcService) { return { op: 'rpc', @@ -47,7 +57,7 @@ export function parseSpanDescription(span: AbstractSpan): SpanDescription { } // If messaging.system exists then this is a messaging system span. - const messagingSystem = attributes[SemanticAttributes.MESSAGING_SYSTEM]; + const messagingSystem = attributes[SEMATTRS_MESSAGING_SYSTEM]; if (messagingSystem) { return { op: 'message', @@ -57,7 +67,7 @@ export function parseSpanDescription(span: AbstractSpan): SpanDescription { } // If faas.trigger exists then this is a function as a service span. - const faasTrigger = attributes[SemanticAttributes.FAAS_TRIGGER]; + const faasTrigger = attributes[SEMATTRS_FAAS_TRIGGER]; if (faasTrigger) { return { op: faasTrigger.toString(), description: name, source: 'route' }; } @@ -67,7 +77,7 @@ export function parseSpanDescription(span: AbstractSpan): SpanDescription { function descriptionForDbSystem({ attributes, name }: { attributes: Attributes; name: string }): SpanDescription { // Use DB statement (Ex "SELECT * FROM table") if possible as description. - const statement = attributes[SemanticAttributes.DB_STATEMENT]; + const statement = attributes[SEMATTRS_DB_STATEMENT]; const description = statement ? statement.toString() : name; @@ -134,11 +144,11 @@ export function getSanitizedUrl( hasRoute: boolean; } { // This is the relative path of the URL, e.g. /sub - const httpTarget = attributes[SemanticAttributes.HTTP_TARGET]; + const httpTarget = attributes[SEMATTRS_HTTP_TARGET]; // This is the full URL, including host & query params etc., e.g. https://example.com/sub?foo=bar - const httpUrl = attributes[SemanticAttributes.HTTP_URL]; + const httpUrl = attributes[SEMATTRS_HTTP_URL]; // This is the normalized route name - may not always be available! - const httpRoute = attributes[SemanticAttributes.HTTP_ROUTE]; + const httpRoute = attributes[SEMATTRS_HTTP_ROUTE]; const parsedUrl = typeof httpUrl === 'string' ? parseUrl(httpUrl) : undefined; const url = parsedUrl ? getSanitizedUrlString(parsedUrl) : undefined; diff --git a/packages/opentelemetry/test/helpers/initOtel.ts b/packages/opentelemetry/test/helpers/initOtel.ts index fb0ac135e015..3a680024811c 100644 --- a/packages/opentelemetry/test/helpers/initOtel.ts +++ b/packages/opentelemetry/test/helpers/initOtel.ts @@ -2,7 +2,11 @@ import { DiagLogLevel, diag } from '@opentelemetry/api'; import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'; import { Resource } from '@opentelemetry/resources'; import { BasicTracerProvider } from '@opentelemetry/sdk-trace-base'; -import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMRESATTRS_SERVICE_NAME, + SEMRESATTRS_SERVICE_NAMESPACE, + SEMRESATTRS_SERVICE_VERSION, +} from '@opentelemetry/semantic-conventions'; import { SDK_VERSION, getClient } from '@sentry/core'; import { logger } from '@sentry/utils'; @@ -51,9 +55,9 @@ export function setupOtel(client: TestClientInterface): BasicTracerProvider { const provider = new BasicTracerProvider({ sampler: new SentrySampler(client), resource: new Resource({ - [SemanticResourceAttributes.SERVICE_NAME]: 'opentelemetry-test', - [SemanticResourceAttributes.SERVICE_NAMESPACE]: 'sentry', - [SemanticResourceAttributes.SERVICE_VERSION]: SDK_VERSION, + [SEMRESATTRS_SERVICE_NAME]: 'opentelemetry-test', + [SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry', + [SEMRESATTRS_SERVICE_VERSION]: SDK_VERSION, }), forceFlushTimeoutMillis: 500, }); diff --git a/packages/opentelemetry/test/trace.test.ts b/packages/opentelemetry/test/trace.test.ts index 4ef8a8d90f6d..ab662b19db5b 100644 --- a/packages/opentelemetry/test/trace.test.ts +++ b/packages/opentelemetry/test/trace.test.ts @@ -21,7 +21,7 @@ import { import type { Event, Scope } from '@sentry/types'; import { makeTraceState } from '../src/propagator'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions'; import { continueTrace, startInactiveSpan, startSpan, startSpanManual } from '../src/trace'; import type { AbstractSpan } from '../src/types'; import { getDynamicSamplingContextFromSpan } from '../src/utils/dynamicSamplingContext'; @@ -1370,35 +1370,26 @@ describe('HTTP methods (sampling)', () => { }); it('does sample when HTTP method is other than OPTIONS or HEAD', () => { - const spanGET = startSpanManual( - { name: 'test span', attributes: { [SemanticAttributes.HTTP_METHOD]: 'GET' } }, - span => { - return span; - }, - ); + const spanGET = startSpanManual({ name: 'test span', attributes: { [SEMATTRS_HTTP_METHOD]: 'GET' } }, span => { + return span; + }); expect(spanIsSampled(spanGET)).toBe(true); expect(getSamplingDecision(spanGET.spanContext())).toBe(true); - const spanPOST = startSpanManual( - { name: 'test span', attributes: { [SemanticAttributes.HTTP_METHOD]: 'POST' } }, - span => { - return span; - }, - ); + const spanPOST = startSpanManual({ name: 'test span', attributes: { [SEMATTRS_HTTP_METHOD]: 'POST' } }, span => { + return span; + }); expect(spanIsSampled(spanPOST)).toBe(true); expect(getSamplingDecision(spanPOST.spanContext())).toBe(true); - const spanPUT = startSpanManual( - { name: 'test span', attributes: { [SemanticAttributes.HTTP_METHOD]: 'PUT' } }, - span => { - return span; - }, - ); + const spanPUT = startSpanManual({ name: 'test span', attributes: { [SEMATTRS_HTTP_METHOD]: 'PUT' } }, span => { + return span; + }); expect(spanIsSampled(spanPUT)).toBe(true); expect(getSamplingDecision(spanPUT.spanContext())).toBe(true); const spanDELETE = startSpanManual( - { name: 'test span', attributes: { [SemanticAttributes.HTTP_METHOD]: 'DELETE' } }, + { name: 'test span', attributes: { [SEMATTRS_HTTP_METHOD]: 'DELETE' } }, span => { return span; }, @@ -1408,23 +1399,17 @@ describe('HTTP methods (sampling)', () => { }); it('does not sample when HTTP method is OPTIONS', () => { - const span = startSpanManual( - { name: 'test span', attributes: { [SemanticAttributes.HTTP_METHOD]: 'OPTIONS' } }, - span => { - return span; - }, - ); + const span = startSpanManual({ name: 'test span', attributes: { [SEMATTRS_HTTP_METHOD]: 'OPTIONS' } }, span => { + return span; + }); expect(spanIsSampled(span)).toBe(false); expect(getSamplingDecision(span.spanContext())).toBe(false); }); it('does not sample when HTTP method is HEAD', () => { - const span = startSpanManual( - { name: 'test span', attributes: { [SemanticAttributes.HTTP_METHOD]: 'HEAD' } }, - span => { - return span; - }, - ); + const span = startSpanManual({ name: 'test span', attributes: { [SEMATTRS_HTTP_METHOD]: 'HEAD' } }, span => { + return span; + }); expect(spanIsSampled(span)).toBe(false); expect(getSamplingDecision(span.spanContext())).toBe(false); }); diff --git a/packages/opentelemetry/test/utils/getRequestSpanData.test.ts b/packages/opentelemetry/test/utils/getRequestSpanData.test.ts index 0edd2befea6c..5b067189740e 100644 --- a/packages/opentelemetry/test/utils/getRequestSpanData.test.ts +++ b/packages/opentelemetry/test/utils/getRequestSpanData.test.ts @@ -1,4 +1,4 @@ -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_URL } from '@opentelemetry/semantic-conventions'; import { getRequestSpanData } from '../../src/utils/getRequestSpanData'; import { createSpan } from '../helpers/createSpan'; @@ -14,8 +14,8 @@ describe('getRequestSpanData', () => { it('works with http span', () => { const span = createSpan(); span.setAttributes({ - [SemanticAttributes.HTTP_URL]: 'http://example.com?foo=bar#baz', - [SemanticAttributes.HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_URL]: 'http://example.com?foo=bar#baz', + [SEMATTRS_HTTP_METHOD]: 'GET', }); const data = getRequestSpanData(span); @@ -31,7 +31,7 @@ describe('getRequestSpanData', () => { it('works without method', () => { const span = createSpan(); span.setAttributes({ - [SemanticAttributes.HTTP_URL]: 'http://example.com', + [SEMATTRS_HTTP_URL]: 'http://example.com', }); const data = getRequestSpanData(span); @@ -45,8 +45,8 @@ describe('getRequestSpanData', () => { it('works with incorrect URL', () => { const span = createSpan(); span.setAttributes({ - [SemanticAttributes.HTTP_URL]: 'malformed-url-here', - [SemanticAttributes.HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_URL]: 'malformed-url-here', + [SEMATTRS_HTTP_METHOD]: 'GET', }); const data = getRequestSpanData(span); diff --git a/packages/opentelemetry/test/utils/mapStatus.test.ts b/packages/opentelemetry/test/utils/mapStatus.test.ts index 5b9e65e36d76..8dcf55a9267b 100644 --- a/packages/opentelemetry/test/utils/mapStatus.test.ts +++ b/packages/opentelemetry/test/utils/mapStatus.test.ts @@ -1,4 +1,4 @@ -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_RPC_GRPC_STATUS_CODE } from '@opentelemetry/semantic-conventions'; import { SPAN_STATUS_ERROR, SPAN_STATUS_OK } from '@sentry/core'; import type { SpanStatus } from '@sentry/types'; @@ -62,11 +62,11 @@ describe('mapStatus', () => { span.setStatus({ code: 0 }); // UNSET if (httpCode) { - span.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, httpCode); + span.setAttribute(SEMATTRS_HTTP_STATUS_CODE, httpCode); } if (grpcCode) { - span.setAttribute(SemanticAttributes.RPC_GRPC_STATUS_CODE, grpcCode); + span.setAttribute(SEMATTRS_RPC_GRPC_STATUS_CODE, grpcCode); } const actual = mapStatus(span); diff --git a/packages/opentelemetry/test/utils/parseSpanDescription.test.ts b/packages/opentelemetry/test/utils/parseSpanDescription.test.ts index aa78526f8ffe..3e25356d1025 100644 --- a/packages/opentelemetry/test/utils/parseSpanDescription.test.ts +++ b/packages/opentelemetry/test/utils/parseSpanDescription.test.ts @@ -1,6 +1,18 @@ import type { Span } from '@opentelemetry/api'; import { SpanKind } from '@opentelemetry/api'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_FAAS_TRIGGER, + SEMATTRS_HTTP_HOST, + SEMATTRS_HTTP_METHOD, + SEMATTRS_HTTP_ROUTE, + SEMATTRS_HTTP_STATUS_CODE, + SEMATTRS_HTTP_TARGET, + SEMATTRS_HTTP_URL, + SEMATTRS_MESSAGING_SYSTEM, + SEMATTRS_RPC_SERVICE, +} from '@opentelemetry/semantic-conventions'; import { descriptionForHttpMethod, getSanitizedUrl, parseSpanDescription } from '../../src/utils/parseSpanDescription'; @@ -31,7 +43,7 @@ describe('parseSpanDescription', () => { [ 'works with http method', { - [SemanticAttributes.HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_METHOD]: 'GET', }, 'test name', SpanKind.CLIENT, @@ -44,8 +56,8 @@ describe('parseSpanDescription', () => { [ 'works with db system', { - [SemanticAttributes.DB_SYSTEM]: 'mysql', - [SemanticAttributes.DB_STATEMENT]: 'SELECT * from users', + [SEMATTRS_DB_SYSTEM]: 'mysql', + [SEMATTRS_DB_STATEMENT]: 'SELECT * from users', }, 'test name', SpanKind.CLIENT, @@ -58,7 +70,7 @@ describe('parseSpanDescription', () => { [ 'works with db system without statement', { - [SemanticAttributes.DB_SYSTEM]: 'mysql', + [SEMATTRS_DB_SYSTEM]: 'mysql', }, 'test name', SpanKind.CLIENT, @@ -71,7 +83,7 @@ describe('parseSpanDescription', () => { [ 'works with rpc service', { - [SemanticAttributes.RPC_SERVICE]: 'rpc-test-service', + [SEMATTRS_RPC_SERVICE]: 'rpc-test-service', }, 'test name', undefined, @@ -84,7 +96,7 @@ describe('parseSpanDescription', () => { [ 'works with messaging system', { - [SemanticAttributes.MESSAGING_SYSTEM]: 'test-messaging-system', + [SEMATTRS_MESSAGING_SYSTEM]: 'test-messaging-system', }, 'test name', undefined, @@ -97,7 +109,7 @@ describe('parseSpanDescription', () => { [ 'works with faas trigger', { - [SemanticAttributes.FAAS_TRIGGER]: 'test-faas-trigger', + [SEMATTRS_FAAS_TRIGGER]: 'test-faas-trigger', }, 'test name', undefined, @@ -131,9 +143,9 @@ describe('descriptionForHttpMethod', () => { 'works with basic client GET', 'GET', { - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_URL]: 'https://www.example.com/my-path', - [SemanticAttributes.HTTP_TARGET]: '/my-path', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_URL]: 'https://www.example.com/my-path', + [SEMATTRS_HTTP_TARGET]: '/my-path', }, 'test name', SpanKind.CLIENT, @@ -150,9 +162,9 @@ describe('descriptionForHttpMethod', () => { 'works with basic server POST', 'POST', { - [SemanticAttributes.HTTP_METHOD]: 'POST', - [SemanticAttributes.HTTP_URL]: 'https://www.example.com/my-path', - [SemanticAttributes.HTTP_TARGET]: '/my-path', + [SEMATTRS_HTTP_METHOD]: 'POST', + [SEMATTRS_HTTP_URL]: 'https://www.example.com/my-path', + [SEMATTRS_HTTP_TARGET]: '/my-path', }, 'test name', SpanKind.SERVER, @@ -169,10 +181,10 @@ describe('descriptionForHttpMethod', () => { 'works with client GET with route', 'GET', { - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_URL]: 'https://www.example.com/my-path/123', - [SemanticAttributes.HTTP_TARGET]: '/my-path/123', - [SemanticAttributes.HTTP_ROUTE]: '/my-path/:id', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_URL]: 'https://www.example.com/my-path/123', + [SEMATTRS_HTTP_TARGET]: '/my-path/123', + [SEMATTRS_HTTP_ROUTE]: '/my-path/:id', }, 'test name', SpanKind.CLIENT, @@ -208,11 +220,11 @@ describe('getSanitizedUrl', () => { [ 'uses url without query for client request', { - [SemanticAttributes.HTTP_URL]: 'http://example.com/?what=true', - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/?what=true', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_URL]: 'http://example.com/?what=true', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/?what=true', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.CLIENT, { @@ -226,11 +238,11 @@ describe('getSanitizedUrl', () => { [ 'uses url without hash for client request', { - [SemanticAttributes.HTTP_URL]: 'http://example.com/sub#hash', - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/sub#hash', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_URL]: 'http://example.com/sub#hash', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/sub#hash', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.CLIENT, { @@ -244,12 +256,12 @@ describe('getSanitizedUrl', () => { [ 'uses route if available for client request', { - [SemanticAttributes.HTTP_URL]: 'http://example.com/?what=true', - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/?what=true', - [SemanticAttributes.HTTP_ROUTE]: '/my-route', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_URL]: 'http://example.com/?what=true', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/?what=true', + [SEMATTRS_HTTP_ROUTE]: '/my-route', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.CLIENT, { @@ -263,10 +275,10 @@ describe('getSanitizedUrl', () => { [ 'falls back to target for client request if url not available', { - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/?what=true', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/?what=true', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.CLIENT, { @@ -280,11 +292,11 @@ describe('getSanitizedUrl', () => { [ 'uses target without query for server request', { - [SemanticAttributes.HTTP_URL]: 'http://example.com/?what=true', - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/?what=true', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_URL]: 'http://example.com/?what=true', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/?what=true', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.SERVER, { @@ -298,11 +310,11 @@ describe('getSanitizedUrl', () => { [ 'uses target without hash for server request', { - [SemanticAttributes.HTTP_URL]: 'http://example.com/?what=true', - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/sub#hash', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_URL]: 'http://example.com/?what=true', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/sub#hash', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.SERVER, { @@ -316,12 +328,12 @@ describe('getSanitizedUrl', () => { [ 'uses route for server request if available', { - [SemanticAttributes.HTTP_URL]: 'http://example.com/?what=true', - [SemanticAttributes.HTTP_METHOD]: 'GET', - [SemanticAttributes.HTTP_TARGET]: '/?what=true', - [SemanticAttributes.HTTP_ROUTE]: '/my-route', - [SemanticAttributes.HTTP_HOST]: 'example.com:80', - [SemanticAttributes.HTTP_STATUS_CODE]: 200, + [SEMATTRS_HTTP_URL]: 'http://example.com/?what=true', + [SEMATTRS_HTTP_METHOD]: 'GET', + [SEMATTRS_HTTP_TARGET]: '/?what=true', + [SEMATTRS_HTTP_ROUTE]: '/my-route', + [SEMATTRS_HTTP_HOST]: 'example.com:80', + [SEMATTRS_HTTP_STATUS_CODE]: 200, }, SpanKind.SERVER, { diff --git a/yarn.lock b/yarn.lock index b6c340ac1d3f..07f83fa7b980 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4888,10 +4888,15 @@ dependencies: "@opentelemetry/context-base" "^0.12.0" -"@opentelemetry/context-async-hooks@1.21.0", "@opentelemetry/context-async-hooks@^1.17.1": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/context-async-hooks/-/context-async-hooks-1.21.0.tgz#a56fa461e7786605bcbde2ff66f21b2392afacda" - integrity sha512-t0iulGPiMjG/NrSjinPQoIf8ST/o9V0dGOJthfrFporJlNdlKIQPfC7lkrV+5s2dyBThfmSbJlp/4hO1eOcDXA== +"@opentelemetry/api@^1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.8.0.tgz#5aa7abb48f23f693068ed2999ae627d2f7d902ec" + integrity sha512-I/s6F7yKUDdtMsoBWXJe8Qz40Tui5vsuKCWJEWVL+5q9sSWRzzx6v2KeNsOBEwd94j0eWkpWCH4yB6rZg9Mf0w== + +"@opentelemetry/context-async-hooks@^1.23.0": + version "1.23.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/context-async-hooks/-/context-async-hooks-1.23.0.tgz#4c4627fe2857324459b0a78b5a83cbc64a415d14" + integrity sha512-wazGJZDRevibOJ+VgyrT+9+8sybZAxpZx2G7vy30OAtk92OpZCg7HgNxT11NUx0VBDWcRx1dOatMYGOVplQ7QA== "@opentelemetry/context-base@^0.12.0": version "0.12.0" @@ -4905,13 +4910,20 @@ dependencies: "@opentelemetry/semantic-conventions" "1.20.0" -"@opentelemetry/core@1.21.0", "@opentelemetry/core@^1.1.0", "@opentelemetry/core@^1.17.1", "@opentelemetry/core@^1.8.0": +"@opentelemetry/core@1.21.0", "@opentelemetry/core@^1.1.0", "@opentelemetry/core@^1.8.0": version "1.21.0" resolved "https://registry.yarnpkg.com/@opentelemetry/core/-/core-1.21.0.tgz#8c16faf16edf861b073c03c9d45977b3f4003ee1" integrity sha512-KP+OIweb3wYoP7qTYL/j5IpOlu52uxBv5M4+QhSmmUfLyTgu1OIS71msK3chFo1D6Y61BIH3wMiMYRCxJCQctA== dependencies: "@opentelemetry/semantic-conventions" "1.21.0" +"@opentelemetry/core@1.23.0", "@opentelemetry/core@^1.23.0": + version "1.23.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/core/-/core-1.23.0.tgz#f2e7ada7f35750f3c1674aef1e52c879005c0731" + integrity sha512-hdQ/a9TMzMQF/BO8Cz1juA43/L5YGtCSiKoOHmrTEf7VMDAZgy8ucpWx3eQTnQ3gBloRcWtzvcrMZABC3PTSKQ== + dependencies: + "@opentelemetry/semantic-conventions" "1.23.0" + "@opentelemetry/core@^0.12.0": version "0.12.0" resolved "https://registry.yarnpkg.com/@opentelemetry/core/-/core-0.12.0.tgz#a888badc9a408fa1f13976a574e69d14be32488e" @@ -5065,20 +5077,6 @@ semver "^7.5.2" shimmer "^1.2.1" -"@opentelemetry/propagator-b3@1.21.0": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-b3/-/propagator-b3-1.21.0.tgz#72fadc4a07afb2c83f0830b8a06071e0361eacb2" - integrity sha512-3ZTobj2VDIOzLsIvvYCdpw6tunxUVElPxDvog9lS49YX4hohHeD84A8u9Ns/6UYUcaN5GSoEf891lzhcBFiOLA== - dependencies: - "@opentelemetry/core" "1.21.0" - -"@opentelemetry/propagator-jaeger@1.21.0": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/propagator-jaeger/-/propagator-jaeger-1.21.0.tgz#bfc1fa3a050496ec67a253040dfdec4d16339225" - integrity sha512-8TQSwXjBmaDx7JkxRD7hdmBmRK2RGRgzHX1ArJfJhIc5trzlVweyorzqQrXOvqVEdEg+zxUMHkL5qbGH/HDTPA== - dependencies: - "@opentelemetry/core" "1.21.0" - "@opentelemetry/resources@1.20.0": version "1.20.0" resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-1.20.0.tgz#7165c39837e6e41b695f0088e40d15a5793f1469" @@ -5095,6 +5093,14 @@ "@opentelemetry/core" "1.21.0" "@opentelemetry/semantic-conventions" "1.21.0" +"@opentelemetry/resources@1.23.0", "@opentelemetry/resources@^1.23.0": + version "1.23.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-1.23.0.tgz#4c71430f3e20c4d88b67ef5629759fae108485e5" + integrity sha512-iPRLfVfcEQynYGo7e4Di+ti+YQTAY0h5mQEUJcHlU9JOqpb4x965O6PZ+wMcwYVY63G96KtdS86YCM1BF1vQZg== + dependencies: + "@opentelemetry/core" "1.23.0" + "@opentelemetry/semantic-conventions" "1.23.0" + "@opentelemetry/resources@^0.12.0": version "0.12.0" resolved "https://registry.yarnpkg.com/@opentelemetry/resources/-/resources-0.12.0.tgz#5eb287c3032a2bebb2bb9f69b44bd160d2a7d591" @@ -5121,37 +5127,30 @@ "@opentelemetry/resources" "1.20.0" "@opentelemetry/semantic-conventions" "1.20.0" -"@opentelemetry/sdk-trace-base@1.21.0", "@opentelemetry/sdk-trace-base@^1.17.1": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.21.0.tgz#ffad912e453a92044fb220bd5d2f6743bf37bb8a" - integrity sha512-yrElGX5Fv0umzp8Nxpta/XqU71+jCAyaLk34GmBzNcrW43nqbrqvdPs4gj4MVy/HcTjr6hifCDCYA3rMkajxxA== - dependencies: - "@opentelemetry/core" "1.21.0" - "@opentelemetry/resources" "1.21.0" - "@opentelemetry/semantic-conventions" "1.21.0" - -"@opentelemetry/sdk-trace-node@^1.17.1": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-node/-/sdk-trace-node-1.21.0.tgz#20599f42a6b59bf71c64ef8630d28464e6e18f2a" - integrity sha512-1pdm8jnqs+LuJ0Bvx6sNL28EhC8Rv7NYV8rnoXq3GIQo7uOHBDAFSj7makAfbakrla7ecO1FRfI8emnR4WvhYA== +"@opentelemetry/sdk-trace-base@^1.23.0": + version "1.23.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.23.0.tgz#ff0a0f8ec47205e0b14b3b765ea2a34de1ad01dd" + integrity sha512-PzBmZM8hBomUqvCddF/5Olyyviayka44O5nDWq673np3ctnvwMOvNrsUORZjKja1zJbwEuD9niAGbnVrz3jwRQ== dependencies: - "@opentelemetry/context-async-hooks" "1.21.0" - "@opentelemetry/core" "1.21.0" - "@opentelemetry/propagator-b3" "1.21.0" - "@opentelemetry/propagator-jaeger" "1.21.0" - "@opentelemetry/sdk-trace-base" "1.21.0" - semver "^7.5.2" + "@opentelemetry/core" "1.23.0" + "@opentelemetry/resources" "1.23.0" + "@opentelemetry/semantic-conventions" "1.23.0" "@opentelemetry/semantic-conventions@1.20.0": version "1.20.0" resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.20.0.tgz#4d9b88188e18056a218644ea30fae130a7857766" integrity sha512-3zLJJCgTKYpbqFX8drl8hOCHtdchELC+kGqlVcV4mHW1DiElTtv1Nt9EKBptTd1IfL56QkuYnWJ3DeHd2Gtu/A== -"@opentelemetry/semantic-conventions@1.21.0", "@opentelemetry/semantic-conventions@^1.0.0", "@opentelemetry/semantic-conventions@^1.17.0", "@opentelemetry/semantic-conventions@^1.17.1": +"@opentelemetry/semantic-conventions@1.21.0", "@opentelemetry/semantic-conventions@^1.0.0", "@opentelemetry/semantic-conventions@^1.17.0": version "1.21.0" resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.21.0.tgz#83f7479c524ab523ac2df702ade30b9724476c72" integrity sha512-lkC8kZYntxVKr7b8xmjCVUgE0a8xgDakPyDo9uSWavXPyYqLgYYGdEd2j8NxihRyb6UwpX3G/hFUF4/9q2V+/g== +"@opentelemetry/semantic-conventions@1.23.0", "@opentelemetry/semantic-conventions@^1.23.0": + version "1.23.0" + resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.23.0.tgz#627f2721b960fe586b7f72a07912cb7699f06eef" + integrity sha512-MiqFvfOzfR31t8cc74CTP1OZfz7MbqpAnLCra8NqQoaHJX6ncIRTdYOQYBDQ2uFISDq0WY8Y9dDTWvsgzzBYRg== + "@opentelemetry/semantic-conventions@^0.12.0": version "0.12.0" resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-0.12.0.tgz#7e392aecdbdbd5d737d3995998b120dc17589ab0"