Skip to content

Commit e617f7f

Browse files
author
Luca Forstner
committed
Add function to include multiple measurements at once
1 parent dd9f8c8 commit e617f7f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/tracing/src/transaction.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class Transaction extends SpanClass implements TransactionInterface {
6969

7070
/**
7171
* Set observed measurement for this transaction.
72+
*
7273
* @param name Name of the measurement
7374
* @param value Value of the measurement
7475
* @param unit Unit of the measurement. (Defaults to an empty string)
@@ -78,6 +79,17 @@ export class Transaction extends SpanClass implements TransactionInterface {
7879
this._measurements[name] = { value, unit };
7980
}
8081

82+
/**
83+
* Set observed measurments for this transaction. This is a convenience function
84+
* instead of multiple `setMeasurement` calls.
85+
*
86+
* @param measurements Measurements to set. Keys represent measurement names.
87+
* Existing measurements with matching names will be overwritten.
88+
*/
89+
public setMeasurements(measurements: Measurements): void {
90+
this._measurements = { ...this._measurements, ...measurements };
91+
}
92+
8193
/**
8294
* Set metadata for this transaction.
8395
* @hidden

0 commit comments

Comments
 (0)