Skip to content

Commit af4e876

Browse files
committed
Revert "avoid using otel tracer"
This reverts commit 6c01021.
1 parent d8e7a54 commit af4e876

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

packages/node-core/src/integrations/http/incoming-requests.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */
22
import type { Span } from '@opentelemetry/api';
3-
import { context, createContextKey, propagation, trace } from '@opentelemetry/api';
3+
import { context, createContextKey, propagation, SpanKind, trace } from '@opentelemetry/api';
44
import type { RPCMetadata } from '@opentelemetry/core';
55
import { getRPCMetadata, isTracingSuppressed, RPCType, setRPCMetadata } from '@opentelemetry/core';
66
import {
@@ -24,7 +24,6 @@ import {
2424
SEMANTIC_ATTRIBUTE_SENTRY_OP,
2525
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
2626
SPAN_STATUS_ERROR,
27-
startInactiveSpan,
2827
stripUrlQueryAndFragment,
2928
withIsolationScope,
3029
} from '@sentry/core';
@@ -189,12 +188,13 @@ export function instrumentServer(
189188
const host = headers.host;
190189
const hostname = host?.replace(/^(.*)(:[0-9]{1,5})/, '$1') || 'localhost';
191190

191+
const tracer = client.tracer;
192192
const scheme = fullUrl.startsWith('https') ? 'https' : 'http';
193193

194-
const span = startInactiveSpan({
195-
name: bestEffortTransactionName,
194+
// We use the plain tracer.startSpan here so we can pass the span kind
195+
const span = tracer.startSpan(bestEffortTransactionName, {
196+
kind: SpanKind.SERVER,
196197
attributes: {
197-
'otel.kind': 'SERVER',
198198
// Sentry specific attributes
199199
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
200200
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.http',
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SpanKind } from '@opentelemetry/api';
22
import type { AbstractSpan } from '../types';
3-
import { spanHasAttributes, spanHasKind } from './spanTypes';
3+
import { spanHasKind } from './spanTypes';
44

55
/**
66
* Get the span kind from a span.
@@ -13,12 +13,5 @@ export function getSpanKind(span: AbstractSpan): SpanKind {
1313
return span.kind;
1414
}
1515

16-
if (spanHasAttributes(span)) {
17-
const kind = span.attributes['otel.kind'];
18-
if (typeof kind === 'string' && SpanKind[kind as keyof typeof SpanKind]) {
19-
return SpanKind[kind as keyof typeof SpanKind];
20-
}
21-
}
22-
2316
return SpanKind.INTERNAL;
2417
}

packages/opentelemetry/test/utils/getSpanKind.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,4 @@ describe('getSpanKind', () => {
88
expect(getSpanKind({} as Span)).toBe(SpanKind.INTERNAL);
99
expect(getSpanKind({ kind: SpanKind.CLIENT } as unknown as Span)).toBe(SpanKind.CLIENT);
1010
});
11-
12-
it('works with attributes', () => {
13-
expect(getSpanKind({ attributes: { 'otel.kind': 'CLIENT' } } as unknown as Span)).toBe(SpanKind.CLIENT);
14-
expect(getSpanKind({ attributes: { 'otel.kind': 'SERVER' } } as unknown as Span)).toBe(SpanKind.SERVER);
15-
expect(getSpanKind({ attributes: { 'otel.kind': 'TEST' } } as unknown as Span)).toBe(SpanKind.INTERNAL);
16-
});
1711
});

0 commit comments

Comments
 (0)