Skip to content

Commit 9298b76

Browse files
committed
replace span.transaction usages in other packages
1 parent 31126f3 commit 9298b76

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

packages/astro/src/server/meta.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
getDynamicSamplingContextFromClient,
33
getDynamicSamplingContextFromSpan,
4+
getRootSpan,
45
spanToTraceHeader,
56
} from '@sentry/core';
67
import type { Client, Scope, Span } from '@sentry/types';
@@ -32,12 +33,12 @@ export function getTracingMetaTags(
3233
client: Client | undefined,
3334
): { sentryTrace: string; baggage?: string } {
3435
const { dsc, sampled, traceId } = scope.getPropagationContext();
35-
const transaction = span?.transaction;
36+
const rootSpan = span && getRootSpan(span);
3637

3738
const sentryTrace = span ? spanToTraceHeader(span) : generateSentryTraceHeader(traceId, undefined, sampled);
3839

39-
const dynamicSamplingContext = transaction
40-
? getDynamicSamplingContextFromSpan(transaction)
40+
const dynamicSamplingContext = rootSpan
41+
? getDynamicSamplingContextFromSpan(rootSpan)
4142
: dsc
4243
? dsc
4344
: client

packages/opentelemetry-node/src/propagator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Baggage, Context, TextMapGetter, TextMapSetter } from '@opentelemetry/api';
22
import { TraceFlags, isSpanContextValid, propagation, trace } from '@opentelemetry/api';
33
import { W3CBaggagePropagator, isTracingSuppressed } from '@opentelemetry/core';
4-
import { getDynamicSamplingContextFromSpan, spanToTraceHeader } from '@sentry/core';
4+
import { getDynamicSamplingContextFromSpan, getRootSpan, spanToTraceHeader } from '@sentry/core';
55
import {
66
SENTRY_BAGGAGE_KEY_PREFIX,
77
baggageHeaderToDynamicSamplingContext,
@@ -35,7 +35,7 @@ export class SentryPropagator extends W3CBaggagePropagator {
3535
if (span) {
3636
setter.set(carrier, SENTRY_TRACE_HEADER, spanToTraceHeader(span));
3737

38-
if (span.transaction) {
38+
if (getRootSpan(span)) {
3939
const dynamicSamplingContext = getDynamicSamplingContextFromSpan(span);
4040
baggage = Object.entries(dynamicSamplingContext).reduce<Baggage>((b, [dscKey, dscValue]) => {
4141
if (dscValue) {

packages/opentelemetry-node/src/utils/spanMap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getRootSpan } from '@sentry/core';
12
import type { Span as SentrySpan } from '@sentry/types';
23

34
interface SpanMapEntry {
@@ -31,7 +32,7 @@ export function getSentrySpan(spanId: string): SentrySpan | undefined {
3132
export function setSentrySpan(spanId: string, sentrySpan: SentrySpan): void {
3233
let ref: SpanRefType = SPAN_REF_ROOT;
3334

34-
const rootSpanId = sentrySpan.transaction?.spanContext().spanId;
35+
const rootSpanId = getRootSpan(sentrySpan)?.spanContext().spanId;
3536

3637
if (rootSpanId && rootSpanId !== spanId) {
3738
const root = SPAN_MAP.get(rootSpanId);

packages/svelte/src/performance.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Span, Transaction } from '@sentry/types';
33
import { afterUpdate, beforeUpdate, onMount } from 'svelte';
44
import { current_component } from 'svelte/internal';
55

6+
import { getRootSpan } from '@sentry/core';
67
import { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';
78
import type { TrackComponentOptions } from './types';
89

@@ -74,7 +75,7 @@ function recordUpdateSpans(componentName: string, initSpan?: Span): void {
7475
// If we are initializing the component when the update span is started, we start it as child
7576
// of the init span. Else, we start it as a child of the transaction.
7677
const parentSpan =
77-
initSpan && !initSpan.endTimestamp && initSpan.transaction === transaction ? initSpan : transaction;
78+
initSpan && !initSpan.endTimestamp && getRootSpan(initSpan) === transaction ? initSpan : transaction;
7879

7980
// eslint-disable-next-line deprecation/deprecation
8081
updateSpan = parentSpan.startChild({

packages/tracing-internal/src/browser/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getCurrentScope,
66
getDynamicSamplingContextFromClient,
77
getDynamicSamplingContextFromSpan,
8+
getRootSpan,
89
hasTracingEnabled,
910
spanToJSON,
1011
spanToTraceHeader,
@@ -21,7 +22,6 @@ import {
2122
stringMatchesSomePattern,
2223
} from '@sentry/utils';
2324

24-
import { getRootSpan } from '@sentry/core/build/types/utils/spanUtils';
2525
import { instrumentFetchRequest } from '../common/fetch';
2626
import { addPerformanceInstrumentationHandler } from './instrument';
2727

packages/tracing-internal/src/common/fetch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getCurrentScope,
55
getDynamicSamplingContextFromClient,
66
getDynamicSamplingContextFromSpan,
7+
getRootSpan,
78
hasTracingEnabled,
89
spanToTraceHeader,
910
} from '@sentry/core';

0 commit comments

Comments
 (0)