Skip to content

Commit f644353

Browse files
authored
feat(core): Use getActiveSpan instead of _getSpanFromScope for logs & metrics (#23223)
Use this API instead of a stack-specific one.
1 parent 6e58443 commit f644353

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/core/src/logs/internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Log, SerializedLog } from '../types/log';
99
import { consoleSandbox, debug } from '../utils/debug-logger';
1010
import { isParameterizedString } from '../utils/is';
1111
import { getCombinedScopeData } from '../utils/scopeData';
12-
import { _getSpanForScope } from '../utils/spanOnScope';
12+
import { getActiveSpan } from '../utils/spanUtils';
1313
import { timestampInSeconds } from '../utils/time';
1414
import { getSequenceAttribute } from '../utils/timestampSequence';
1515
import { _getTraceInfoFromScope } from '../utils/trace-info';
@@ -138,7 +138,7 @@ export function _INTERNAL_captureLog(
138138
});
139139
}
140140

141-
const span = _getSpanForScope(currentScope);
141+
const span = getActiveSpan(currentScope);
142142
// Add the parent span ID to the log attributes for trace context
143143
setLogAttribute(processedLogAttributes, 'sentry.trace.parent_span_id', span?.spanContext().spanId);
144144

packages/core/src/metrics/internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Metric, SerializedMetric } from '../types/metric';
99
import type { User } from '../types/user';
1010
import { debug } from '../utils/debug-logger';
1111
import { getCombinedScopeData } from '../utils/scopeData';
12-
import { _getSpanForScope } from '../utils/spanOnScope';
12+
import { getActiveSpan } from '../utils/spanUtils';
1313
import { timestampInSeconds } from '../utils/time';
1414
import { getSequenceAttribute } from '../utils/timestampSequence';
1515
import { _getTraceInfoFromScope } from '../utils/trace-info';
@@ -132,7 +132,7 @@ function _buildSerializedMetric(
132132
): SerializedMetric {
133133
// Get trace context
134134
const [, traceContext] = _getTraceInfoFromScope(client, currentScope);
135-
const span = _getSpanForScope(currentScope);
135+
const span = getActiveSpan(currentScope);
136136
const traceId = span ? span.spanContext().traceId : traceContext?.trace_id;
137137
const spanId = span ? span.spanContext().spanId : undefined;
138138

0 commit comments

Comments
 (0)