Skip to content

Commit 9a1b12e

Browse files
Merge branch 'egou/v7/feat/add-exclusive-time-and-measurements-to-spans' of github.com:getsentry/sentry-javascript into egou/v7/feat/create-interaction-spans-on-inp
2 parents 19cf74a + 7156838 commit 9a1b12e

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

packages/core/src/semanticAttributes.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,3 @@ export const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';
1919
* Use this attribute to represent the origin of a span.
2020
*/
2121
export const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';
22-
23-
/**
24-
* Use this attribute to represent measurements of a span.
25-
*/
26-
export const SEMANTIC_ATTRIBUTE_MEASUREMENTS = 'measurements';

packages/core/src/tracing/span.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ import { dropUndefinedKeys, logger, timestampInSeconds, uuid4 } from '@sentry/ut
1818

1919
import { DEBUG_BUILD } from '../debug-build';
2020
import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary';
21-
import {
22-
SEMANTIC_ATTRIBUTE_MEASUREMENTS,
23-
SEMANTIC_ATTRIBUTE_SENTRY_OP,
24-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
25-
} from '../semanticAttributes';
21+
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
2622
import { getRootSpan } from '../utils/getRootSpan';
2723
import {
2824
TRACE_FLAG_NONE,
@@ -122,6 +118,8 @@ export class Span implements SpanInterface {
122118
protected _status?: SpanStatusType | string | undefined;
123119
protected _exclusiveTime?: number;
124120

121+
protected _measurements: Measurements;
122+
125123
private _logMessage?: string;
126124

127125
/**
@@ -168,6 +166,7 @@ export class Span implements SpanInterface {
168166
if (spanContext.exclusiveTime) {
169167
this._exclusiveTime = spanContext.exclusiveTime;
170168
}
169+
this._measurements = spanContext.measurements ? { ...spanContext.measurements } : {};
171170
}
172171

173172
// This rule conflicts with another eslint rule :(
@@ -636,7 +635,7 @@ export class Span implements SpanInterface {
636635
origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,
637636
_metrics_summary: getMetricSummaryJsonForSpan(this),
638637
exclusive_time: this._exclusiveTime,
639-
measurements: this._attributes[SEMANTIC_ATTRIBUTE_MEASUREMENTS] as Measurements | undefined,
638+
measurements: Object.keys(this._measurements).length > 0 ? this._measurements : undefined,
640639
});
641640
}
642641

packages/core/src/tracing/transaction.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {
33
Contexts,
44
DynamicSamplingContext,
55
MeasurementUnit,
6-
Measurements,
76
SpanTimeInput,
87
Transaction as TransactionInterface,
98
TransactionContext,
@@ -31,8 +30,6 @@ export class Transaction extends SpanClass implements TransactionInterface {
3130

3231
protected _name: string;
3332

34-
private _measurements: Measurements;
35-
3633
private _contexts: Contexts;
3734

3835
private _trimEnd?: boolean | undefined;
@@ -53,7 +50,6 @@ export class Transaction extends SpanClass implements TransactionInterface {
5350
*/
5451
public constructor(transactionContext: TransactionContext, hub?: Hub) {
5552
super(transactionContext);
56-
this._measurements = {};
5753
this._contexts = {};
5854

5955
// eslint-disable-next-line deprecation/deprecation

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ describe('span', () => {
105105
it('disallows invalid attribute types', () => {
106106
const span = new Span();
107107

108+
/** @ts-expect-error this is invalid */
109+
span.setAttribute('str', {});
110+
108111
/** @ts-expect-error this is invalid */
109112
span.setAttribute('str', null);
110113

packages/types/src/span.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ export type SpanAttributeValue =
2222
| boolean
2323
| Array<null | undefined | string>
2424
| Array<null | undefined | number>
25-
| Array<null | undefined | boolean>
26-
| Measurements;
25+
| Array<null | undefined | boolean>;
2726

2827
export type SpanAttributes = Partial<{
2928
'sentry.origin': string;
3029
'sentry.op': string;
3130
'sentry.source': string;
3231
'sentry.sample_rate': number;
33-
measurements: Measurements;
3432
}> &
3533
Record<string, SpanAttributeValue | undefined>;
3634

@@ -186,6 +184,11 @@ export interface SpanContext {
186184
* Exclusive time in milliseconds.
187185
*/
188186
exclusiveTime?: number;
187+
188+
/**
189+
* Measurements of the Span.
190+
*/
191+
measurements?: Measurements;
189192
}
190193

191194
/** Span holding trace_id, span_id */

0 commit comments

Comments
 (0)