-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(measurements): Update
setMeasurements
to only set a single meas…
…urement (#4920)
- Loading branch information
Showing
5 changed files
with
62 additions
and
19 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
packages/integration-tests/suites/public-api/startTransaction/setMeasurement/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const transaction = Sentry.startTransaction({ name: 'some_transaction' }); | ||
|
||
transaction.setMeasurement('metric.foo', 42, 'ms'); | ||
transaction.setMeasurement('metric.bar', 1337, 'nanoseconds'); | ||
transaction.setMeasurement('metric.baz', 99, 's'); | ||
transaction.setMeasurement('metric.baz', 1); | ||
|
||
transaction.finish(); |
18 changes: 18 additions & 0 deletions
18
packages/integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; | ||
|
||
sentryTest('should attach measurement to transaction', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
const event = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(event.measurements?.['metric.foo'].value).toBe(42); | ||
expect(event.measurements?.['metric.bar'].value).toBe(1337); | ||
expect(event.measurements?.['metric.baz'].value).toBe(1); | ||
|
||
expect(event.measurements?.['metric.foo'].unit).toBe('ms'); | ||
expect(event.measurements?.['metric.bar'].unit).toBe('nanoseconds'); | ||
expect(event.measurements?.['metric.baz'].unit).toBe(''); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters