11import type {
22 Contexts ,
33 Hub ,
4- MeasurementUnit ,
5- Measurements ,
64 SpanJSON ,
75 SpanTimeInput ,
86 Transaction as TransactionInterface ,
@@ -18,6 +16,7 @@ import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary';
1816import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes' ;
1917import { getSpanDescendants , spanTimeInputToSeconds , spanToJSON , spanToTraceContext } from '../utils/spanUtils' ;
2018import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext' ;
19+ import { timedEventsToMeasurements } from './measurement' ;
2120import { SentrySpan } from './sentrySpan' ;
2221import { getCapturedScopesOnSpan } from './utils' ;
2322
@@ -30,8 +29,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
3029
3130 protected _name : string ;
3231
33- private _measurements : Measurements ;
34-
3532 private _contexts : Contexts ;
3633
3734 private _trimEnd ?: boolean | undefined ;
@@ -46,7 +43,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
4643 */
4744 public constructor ( transactionContext : TransactionArguments , hub ?: Hub ) {
4845 super ( transactionContext ) ;
49- this . _measurements = { } ;
5046 this . _contexts = { } ;
5147
5248 // eslint-disable-next-line deprecation/deprecation
@@ -69,15 +65,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
6965 return this ;
7066 }
7167
72- /**
73- * @inheritDoc
74- *
75- * @deprecated Use top-level `setMeasurement()` instead.
76- */
77- public setMeasurement ( name : string , value : number , unit : MeasurementUnit = '' ) : void {
78- this . _measurements [ name ] = { value, unit } ;
79- }
80-
8168 /**
8269 * @inheritDoc
8370 */
@@ -169,15 +156,13 @@ export class Transaction extends SentrySpan implements TransactionInterface {
169156 } ) ,
170157 } ;
171158
172- const hasMeasurements = Object . keys ( this . _measurements ) . length > 0 ;
159+ const measurements = timedEventsToMeasurements ( this . _events ) ;
160+ const hasMeasurements = Object . keys ( measurements ) . length ;
173161
174162 if ( hasMeasurements ) {
175163 DEBUG_BUILD &&
176- logger . log (
177- '[Measurements] Adding measurements to transaction' ,
178- JSON . stringify ( this . _measurements , undefined , 2 ) ,
179- ) ;
180- transaction . measurements = this . _measurements ;
164+ logger . log ( '[Measurements] Adding measurements to transaction' , JSON . stringify ( measurements , undefined , 2 ) ) ;
165+ transaction . measurements = measurements ;
181166 }
182167
183168 return transaction ;
0 commit comments