Skip to content

Commit 378cf53

Browse files
msonnbcodex
andcommitted
fix(core): strip internal custom span name from streamed spans
Co-Authored-By: OpenAI ChatGPT <codex@openai.com>
1 parent 061f62c commit 378cf53

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/pageload-updateSpanName/test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sentryTest(
3434
[SENTRY_OP]: { type: 'string', value: 'pageload' },
3535
});
3636

37-
expect(attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]).toEqual({ type: 'string', value: 'new name' });
37+
expect(attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]).toBeUndefined();
3838

3939
expect(pageloadSpan.name).toBe('new name');
4040

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,16 @@ 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+
273277
return {
274278
...spanJson,
275279
// We only ever send ended spans, but fall back to the start time (i.e. duration 0) so that
276280
// sent spans always carry an end timestamp.
277281
end_timestamp: spanJson.end_timestamp ?? spanJson.start_timestamp,
278-
attributes: serializeAttributes(spanJson.attributes),
282+
attributes,
279283
links: spanJson.links?.map(link => ({
280284
...link,
281285
attributes: serializeAttributes(link.attributes),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Scope,
77
SentryNonRecordingSpan,
88
SentrySpan,
9+
SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,
910
setCurrentClient,
1011
SPAN_STATUS_ERROR,
1112
SPAN_STATUS_OK,
@@ -681,6 +682,7 @@ describe('spanToStaticSpanJSON', () => {
681682
attr2: 2,
682683
attr3: true,
683684
attr4: [1, 2, 3],
685+
[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: 'test name',
684686
[SENTRY_OP]: 'test op',
685687
[SENTRY_ORIGIN]: 'auto',
686688
},

0 commit comments

Comments
 (0)