File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
packages/tracing/src/browser Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ export const DEFAULT_MAX_TRANSACTION_DURATION_SECONDS = 600;
20
20
21
21
/** Options for Browser Tracing integration */
22
22
export interface BrowserTracingOptions extends RequestInstrumentationOptions {
23
+ /**
24
+ * Flag to attach measurements to transactions.
25
+ *
26
+ * Default: false
27
+ * @hidden
28
+ */
29
+ enableMeasurements : boolean ;
30
+
23
31
/**
24
32
* The time to wait in ms until the transaction will be finished. The transaction will use the end timestamp of
25
33
* the last finished span as the endtime for the transaction.
@@ -95,6 +103,7 @@ export class BrowserTracing implements Integration {
95
103
96
104
/** Browser Tracing integration options */
97
105
public options : BrowserTracingOptions = {
106
+ enableMeasurements : false ,
98
107
beforeNavigate : defaultBeforeNavigate ,
99
108
idleTimeout : DEFAULT_IDLE_TIMEOUT ,
100
109
markBackgroundTransactions : true ,
@@ -135,6 +144,8 @@ export class BrowserTracing implements Integration {
135
144
..._options ,
136
145
tracingOrigins,
137
146
} ;
147
+
148
+ this . _metrics . enableMeasurements ( this . options . enableMeasurements ) ;
138
149
}
139
150
140
151
/**
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const global = getGlobalObject<Window>();
19
19
export class MetricsInstrumentation {
20
20
private _lcp : Record < string , any > = { } ;
21
21
private _measurements : Measurements = { } ;
22
+ private _enableMeasurements : boolean = false ;
22
23
23
24
private _performanceCursor : number = 0 ;
24
25
@@ -33,6 +34,15 @@ export class MetricsInstrumentation {
33
34
}
34
35
}
35
36
37
+ /**
38
+ * Enable or disable attachment of measurements to transactions.
39
+ * @hidden
40
+ */
41
+ public enableMeasurements ( enable : boolean ) : void {
42
+ this . _enableMeasurements = enable ;
43
+ }
44
+
45
+
36
46
/** Add performance related spans to a transaction */
37
47
public addPerformanceEntries ( transaction : Transaction ) : void {
38
48
if ( ! global || ! global . performance || ! global . performance . getEntries ) {
@@ -136,7 +146,7 @@ export class MetricsInstrumentation {
136
146
this . _performanceCursor = Math . max ( performance . getEntries ( ) . length - 1 , 0 ) ;
137
147
138
148
// Measurements are only available for pageload transactions
139
- if ( transaction . op === 'pageload' ) {
149
+ if ( transaction . op === 'pageload' && this . _enableMeasurements ) {
140
150
transaction . setMeasurements ( this . _measurements ) ;
141
151
}
142
152
}
You can’t perform that action at this time.
0 commit comments