Skip to content

Commit 34b69b3

Browse files
authored
ref: Avoid dropUndefinedKeys for spanToJSON calls (#15792)
We probably don't need this!
1 parent fa9376c commit 34b69b3

File tree

3 files changed

+4
-25
lines changed

3 files changed

+4
-25
lines changed

packages/core/src/tracing/sentrySpan.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import type {
2626
} from '../types-hoist';
2727
import type { SpanLink } from '../types-hoist/link';
2828
import { logger } from '../utils-hoist/logger';
29-
import { dropUndefinedKeys } from '../utils-hoist/object';
3029
import { generateSpanId, generateTraceId } from '../utils-hoist/propagationContext';
3130
import { timestampInSeconds } from '../utils-hoist/time';
3231
import {
@@ -223,7 +222,7 @@ export class SentrySpan implements Span {
223222
* use `spanToJSON(span)` instead.
224223
*/
225224
public getSpanJSON(): SpanJSON {
226-
return dropUndefinedKeys({
225+
return {
227226
data: this._attributes,
228227
description: this._name,
229228
op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
@@ -240,7 +239,7 @@ export class SentrySpan implements Span {
240239
is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,
241240
segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,
242241
links: convertSpanLinksForEnvelope(this._links),
243-
});
242+
};
244243
}
245244

246245
/** @inheritdoc */

packages/core/src/utils/spanUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function spanToJSON(span: Span): SpanJSON {
147147
if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
148148
const { attributes, startTime, name, endTime, parentSpanId, status, links } = span;
149149

150-
return dropUndefinedKeys({
150+
return {
151151
span_id,
152152
trace_id,
153153
data: attributes,
@@ -160,7 +160,7 @@ export function spanToJSON(span: Span): SpanJSON {
160160
op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
161161
origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,
162162
links: convertSpanLinksForEnvelope(links),
163-
});
163+
};
164164
}
165165

166166
// Finally, at least we have `spanContext()`....

packages/core/test/lib/tracing/sentrySpan.test.ts

-20
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,6 @@ describe('SentrySpan', () => {
7575
expect(serialized).toHaveProperty('span_id', 'd');
7676
expect(serialized).toHaveProperty('trace_id', 'c');
7777
});
78-
79-
test('should drop all `undefined` values', () => {
80-
const spanA = new SentrySpan({ traceId: 'a', spanId: 'b' });
81-
const spanB = new SentrySpan({
82-
parentSpanId: spanA.spanContext().spanId,
83-
spanId: 'd',
84-
traceId: 'c',
85-
});
86-
const serialized = spanToJSON(spanB);
87-
expect(serialized).toStrictEqual({
88-
start_timestamp: expect.any(Number),
89-
parent_span_id: 'b',
90-
span_id: 'd',
91-
trace_id: 'c',
92-
origin: 'manual',
93-
data: {
94-
'sentry.origin': 'manual',
95-
},
96-
});
97-
});
9878
});
9979

10080
describe('end', () => {

0 commit comments

Comments
 (0)