Skip to content

Commit 1da510d

Browse files
committed
remove carrier hack
1 parent 309242e commit 1da510d

File tree

4 files changed

+11
-59
lines changed

4 files changed

+11
-59
lines changed

packages/node/src/integrations/http.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { Span } from '@opentelemetry/api';
33
import { SpanKind } from '@opentelemetry/api';
44
import { registerInstrumentations } from '@opentelemetry/instrumentation';
55
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
6-
import { storeRequestUrlOnPropagationCarrier } from '@sentry/opentelemetry';
76

87
import {
98
addBreadcrumb,
@@ -66,12 +65,6 @@ const _httpIntegration = ((options: HttpOptions = {}) => {
6665
return true;
6766
}
6867

69-
// We keep the URL on the headers (which are the carrier for the propagator)
70-
// so we can access it in the propagator to check against tracePropagationTargets
71-
const headers = request.headers || {};
72-
storeRequestUrlOnPropagationCarrier(headers, url);
73-
request.headers = headers;
74-
7568
if (_ignoreOutgoingRequests && _ignoreOutgoingRequests(url)) {
7669
return true;
7770
}

packages/opentelemetry/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export {
1717
} from './utils/spanTypes';
1818

1919
export { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext';
20-
export { storeRequestUrlOnPropagationCarrier } from './utils/storeRequestUrlForPropagation';
2120

2221
export { isSentryRequestSpan } from './utils/isSentryRequest';
2322

packages/opentelemetry/src/propagator.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { getScopesFromContext, setScopesOnContext } from './utils/contextData';
3434
import { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext';
3535
import { getSamplingDecision } from './utils/getSamplingDecision';
3636
import { setIsSetup } from './utils/setupCheck';
37-
import { getAndCleanRequestUrlFromPropagationCarrier } from './utils/storeRequestUrlForPropagation';
3837

3938
/** Get the Sentry propagation context from a span context. */
4039
export function getPropagationContextFromSpan(span: Span): PropagationContext {
@@ -87,7 +86,7 @@ export class SentryPropagator extends W3CBaggagePropagator {
8786
}
8887

8988
const activeSpan = trace.getSpan(context);
90-
const url = getCurrentURL(carrier as { __requestUrl?: string }, activeSpan);
89+
const url = activeSpan && getCurrentURL(activeSpan);
9190

9291
const tracePropagationTargets = getClient()?.getOptions()?.tracePropagationTargets;
9392
if (
@@ -328,25 +327,18 @@ function getExistingBaggage(carrier: unknown): string | undefined {
328327
* So we use the following logic:
329328
* 1. If we have an active span, we check if it has a URL attribute.
330329
* 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).
331-
* 3. Finally, we look at a special header on the carrier, which we set in the http integration.
332330
*/
333-
function getCurrentURL(carrier: Record<string, unknown>, span: Span | undefined): string | undefined {
334-
// This may be set in the http integration
335-
// We call this first to ensure the carrier is always cleaned, but we only use it if we don't have any url on the span
336-
const urlFromCarrier = getAndCleanRequestUrlFromPropagationCarrier(carrier);
337-
338-
if (span) {
339-
const urlAttribute = spanToJSON(span).data?.[SemanticAttributes.HTTP_URL];
340-
if (urlAttribute) {
341-
return urlAttribute;
342-
}
331+
function getCurrentURL(span: Span): string | undefined {
332+
const urlAttribute = spanToJSON(span).data?.[SemanticAttributes.HTTP_URL];
333+
if (urlAttribute) {
334+
return urlAttribute;
335+
}
343336

344-
// Also look at the traceState, which we may set in the sampler even for unsampled spans
345-
const urlTraceState = span.spanContext().traceState?.get(SENTRY_TRACE_STATE_URL);
346-
if (urlTraceState) {
347-
return urlTraceState;
348-
}
337+
// Also look at the traceState, which we may set in the sampler even for unsampled spans
338+
const urlTraceState = span.spanContext().traceState?.get(SENTRY_TRACE_STATE_URL);
339+
if (urlTraceState) {
340+
return urlTraceState;
349341
}
350342

351-
return urlFromCarrier;
343+
return undefined;
352344
}

packages/opentelemetry/src/utils/storeRequestUrlForPropagation.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)