diff --git a/packages/core/src/tracing/span.ts b/packages/core/src/tracing/span.ts index 5ded23cc386d..6937f5502804 100644 --- a/packages/core/src/tracing/span.ts +++ b/packages/core/src/tracing/span.ts @@ -1,6 +1,7 @@ /* eslint-disable max-lines */ import type { Instrumenter, + Measurements, Primitive, Span as SpanInterface, SpanAttributeValue, @@ -115,6 +116,9 @@ export class Span implements SpanInterface { protected _endTime?: number | undefined; /** Internal keeper of the status */ protected _status?: SpanStatusType | string | undefined; + protected _exclusiveTime?: number; + + protected _measurements: Measurements; private _logMessage?: string; @@ -159,6 +163,10 @@ export class Span implements SpanInterface { if (spanContext.endTimestamp) { this._endTime = spanContext.endTimestamp; } + if (spanContext.exclusiveTime) { + this._exclusiveTime = spanContext.exclusiveTime; + } + this._measurements = spanContext.measurements ? { ...spanContext.measurements } : {}; } // This rule conflicts with another eslint rule :( @@ -626,6 +634,8 @@ export class Span implements SpanInterface { trace_id: this._traceId, origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined, _metrics_summary: getMetricSummaryJsonForSpan(this), + exclusive_time: this._exclusiveTime, + measurements: Object.keys(this._measurements).length > 0 ? this._measurements : undefined, }); } diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index 8f82c9b03d95..905aaf6c5040 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -3,7 +3,6 @@ import type { Contexts, DynamicSamplingContext, MeasurementUnit, - Measurements, SpanTimeInput, Transaction as TransactionInterface, TransactionContext, @@ -31,8 +30,6 @@ export class Transaction extends SpanClass implements TransactionInterface { protected _name: string; - private _measurements: Measurements; - private _contexts: Contexts; private _trimEnd?: boolean | undefined; @@ -53,7 +50,6 @@ export class Transaction extends SpanClass implements TransactionInterface { */ public constructor(transactionContext: TransactionContext, hub?: Hub) { super(transactionContext); - this._measurements = {}; this._contexts = {}; // eslint-disable-next-line deprecation/deprecation diff --git a/packages/types/src/span.ts b/packages/types/src/span.ts index 69704d497b8f..4b803b73464f 100644 --- a/packages/types/src/span.ts +++ b/packages/types/src/span.ts @@ -1,5 +1,6 @@ import type { TraceContext } from './context'; import type { Instrumenter } from './instrumenter'; +import type { Measurements } from './measurement'; import type { Primitive } from './misc'; import type { HrTime } from './opentelemetry'; import type { Transaction } from './transaction'; @@ -178,6 +179,16 @@ export interface SpanContext { * The origin of the span, giving context about what created the span. */ origin?: SpanOrigin | undefined; + + /** + * Exclusive time in milliseconds. + */ + exclusiveTime?: number; + + /** + * Measurements of the Span. + */ + measurements?: Measurements; } /** Span holding trace_id, span_id */