Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/src/metrics/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Scope } from '../scope';
import type { MetricUnit } from '../types/measurement';
import type { Metric, MetricType } from '../types/metric';
import { _INTERNAL_captureMetric } from './internal';

Expand All @@ -9,7 +10,7 @@ export interface MetricOptions {
/**
* The unit of the metric value.
*/
unit?: string;
unit?: MetricUnit;

/**
* Arbitrary structured data that stores information about the metric.
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ export type {
InformationUnit,
FractionUnit,
MeasurementUnit,
MetricUnit,
NoneUnit,
Measurements,
} from './types/measurement';
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/types/measurement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ type LiteralUnion<T extends string> = T | Omit<T, T>;
export type MeasurementUnit = LiteralUnion<DurationUnit | InformationUnit | FractionUnit | NoneUnit>;

export type Measurements = Record<string, { value: number; unit: MeasurementUnit }>;

// Unlike MeasurementUnit, metric units have no NoneUnit: a unitless metric omits the unit field
// rather than sending 'none'. See https://develop.sentry.dev/sdk/telemetry/attributes/#units
export type MetricUnit = LiteralUnion<DurationUnit | InformationUnit | FractionUnit>;
5 changes: 3 additions & 2 deletions packages/core/src/types/metric.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Attributes, TypedAttributeValue } from '../attributes';
import type { MetricUnit } from './measurement';

export type MetricType = 'counter' | 'gauge' | 'distribution';

Expand All @@ -21,7 +22,7 @@ export interface Metric {
/**
* The unit of the metric value.
*/
unit?: string;
unit?: MetricUnit;

/**
* Arbitrary structured data that stores information about the metric.
Expand Down Expand Up @@ -63,7 +64,7 @@ export interface SerializedMetric {
/**
* The unit of the metric value.
*/
unit?: string;
unit?: MetricUnit;

/**
* The value of the metric.
Expand Down
Loading