Skip to content

Commit 57789a7

Browse files
committed
move to captureSpan
1 parent 7c77821 commit 57789a7

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎packages/core/src/tracing/spans/captureSpan.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { RawAttributes } from '../../attributes';
22
import type { Client } from '../../client';
33
import type { ScopeData } from '../../scope';
4+
import { SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME } from '../../semanticAttributes';
45
import type { SerializedStreamedSpan, Span, SpanAttributeValue, SpanJSON, StreamedSpanJSON } from '../../types/span';
56
import { getCombinedScopeData } from '../../utils/scopeData';
67
import {
@@ -45,6 +46,10 @@ export type SerializedStreamedSpanWithSegmentSpan = SerializedStreamedSpan & {
4546
export function captureSpan(span: Span, client: Client): SerializedStreamedSpanWithSegmentSpan {
4647
// Convert to JSON FIRST - we cannot write to an already-ended span
4748
const spanJSON = spanToJSON(span);
49+
if (spanJSON.attributes) {
50+
// oxlint-disable-next-line typescript/no-dynamic-delete
51+
delete spanJSON.attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
52+
}
4853

4954
const segmentSpan = INTERNAL_getSegmentSpan(span);
5055
const serializedSegmentSpan = spanToJSON(segmentSpan);

‎packages/core/src/utils/spanUtils.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,12 @@ function getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | unde
270270
* The returned serilaized spans must not be consumed by users or SDK integrations.
271271
*/
272272
export function streamedSpanJsonToSerializedSpan(spanJson: StreamedSpanJSON): SerializedStreamedSpan {
273-
const attributes = serializeAttributes(spanJson.attributes);
274-
// oxlint-disable-next-line typescript/no-dynamic-delete
275-
delete attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
276-
277273
return {
278274
...spanJson,
279275
// We only ever send ended spans, but fall back to the start time (i.e. duration 0) so that
280276
// sent spans always carry an end timestamp.
281277
end_timestamp: spanJson.end_timestamp ?? spanJson.start_timestamp,
282-
attributes,
278+
attributes: serializeAttributes(spanJson.attributes),
283279
links: spanJson.links?.map(link => ({
284280
...link,
285281
attributes: serializeAttributes(link.attributes),

‎packages/core/test/lib/utils/spanUtils.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
Scope,
77
SentryNonRecordingSpan,
88
SentrySpan,
9-
SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,
109
setCurrentClient,
1110
SPAN_STATUS_ERROR,
1211
SPAN_STATUS_OK,
@@ -682,7 +681,6 @@ describe('spanToStaticSpanJSON', () => {
682681
attr2: 2,
683682
attr3: true,
684683
attr4: [1, 2, 3],
685-
[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: 'test name',
686684
[SENTRY_OP]: 'test op',
687685
[SENTRY_ORIGIN]: 'auto',
688686
},

0 commit comments

Comments
 (0)