Skip to content

Commit

Permalink
feat(core): Add setMeasurement export (#8791)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Aug 11, 2023
1 parent 7bba7eb commit 2cd6ea5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export {
export type { RequestInstrumentationOptions } from '@sentry-internal/tracing';
export {
addTracingExtensions,
setMeasurement,
extractTraceparentData,
getActiveTransaction,
spanStatusfromHttpCode,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/tracing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { SpanStatus } from './spanstatus';
export type { SpanStatusType } from './span';
export { trace } from './trace';
export { getDynamicSamplingContextFromClient } from './dynamicSamplingContext';
export { setMeasurement } from './measurement';
13 changes: 13 additions & 0 deletions packages/core/src/tracing/measurement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { MeasurementUnit } from '@sentry/types';

import { getActiveTransaction } from './utils';

/**
* Adds a measurement to the current active transaction.
*/
export function setMeasurement(name: string, value: number, unit: MeasurementUnit): void {
const transaction = getActiveTransaction();
if (transaction) {
transaction.setMeasurement(name, value, unit);
}
}
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export {
trace,
withScope,
captureCheckIn,
setMeasurement,
} from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';
export { autoDiscoverNodePerformanceMonitoringIntegrations } from './tracing';
Expand Down
1 change: 1 addition & 0 deletions packages/serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ export {
deepReadDirSync,
Handlers,
Integrations,
setMeasurement,
} from '@sentry/node';
1 change: 1 addition & 0 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export {
deepReadDirSync,
Integrations,
Handlers,
setMeasurement,
} from '@sentry/node';

// We can still leave this for the carrier init and type exports
Expand Down

0 comments on commit 2cd6ea5

Please sign in to comment.