Skip to content
10 changes: 10 additions & 0 deletions packages/core/src/tracing/span.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable max-lines */
import type {
Instrumenter,
Measurements,
Primitive,
Span as SpanInterface,
SpanAttributeValue,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 :(
Expand Down Expand Up @@ -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,
});
}

Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/tracing/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {
Contexts,
DynamicSamplingContext,
MeasurementUnit,
Measurements,
SpanTimeInput,
Transaction as TransactionInterface,
TransactionContext,
Expand Down Expand Up @@ -31,8 +30,6 @@ export class Transaction extends SpanClass implements TransactionInterface {

protected _name: string;

private _measurements: Measurements;

private _contexts: Contexts;

private _trimEnd?: boolean | undefined;
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions packages/types/src/span.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 */
Expand Down