MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / getSpanJSON

Method getSpanJSON

packages/core/src/tracing/sentrySpan.ts:236–255  ·  view source on GitHub ↗

* Get JSON representation of this span. * * @hidden * @internal This method is purely for internal purposes and should not be used outside * of SDK code. If you need to get a JSON representation of a span, * use `spanToJSON(span)` instead.

()

Source from the content-addressed store, hash-verified

234 * use `spanToJSON(span)` instead.
235 */
236 public getSpanJSON(): SpanJSON {
237 return {
238 data: this._attributes,
239 description: this._name,
240 op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
241 parent_span_id: this._parentSpanId,
242 span_id: this._spanId,
243 start_timestamp: this._startTime,
244 status: getStatusMessage(this._status),
245 timestamp: this._endTime,
246 trace_id: this._traceId,
247 origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,
248 profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined,
249 exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] as number | undefined,
250 measurements: timedEventsToMeasurements(this._events),
251 is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,
252 segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,
253 links: convertSpanLinksForEnvelope(this._links),
254 };
255 }
256
257 /**
258 * Get {@link StreamedSpanJSON} representation of this span.

Callers 1

spanToJSONFunction · 0.45

Calls 5

getStatusMessageFunction · 0.90
getRootSpanFunction · 0.85
spanContextMethod · 0.65

Tested by

no test coverage detected