Skip to content

Commit f5d6333

Browse files
committed
use metric constants
1 parent e698dfa commit f5d6333

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

packages/core/src/metrics/exports.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { logger } from '@sentry/utils';
33
import type { BaseClient } from '../baseclient';
44
import { DEBUG_BUILD } from '../debug-build';
55
import { getCurrentHub } from '../hub';
6+
import { COUNTER_METRIC_TYPE, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, SET_METRIC_TYPE } from './constants';
67
import type { MetricType } from './types';
78

89
interface MetricData {
@@ -48,7 +49,7 @@ function addToMetricsAggregator(metricType: MetricType, name: string, value: num
4849
* @experimental This API is experimental and might having breaking changes in the future.
4950
*/
5051
export function incr(name: string, value: number, data?: MetricData): void {
51-
addToMetricsAggregator('c', name, value, data);
52+
addToMetricsAggregator(COUNTER_METRIC_TYPE, name, value, data);
5253
}
5354

5455
/**
@@ -57,7 +58,7 @@ export function incr(name: string, value: number, data?: MetricData): void {
5758
* @experimental This API is experimental and might having breaking changes in the future.
5859
*/
5960
export function distribution(name: string, value: number, data?: MetricData): void {
60-
addToMetricsAggregator('d', name, value, data);
61+
addToMetricsAggregator(DISTRIBUTION_METRIC_TYPE, name, value, data);
6162
}
6263

6364
/**
@@ -66,7 +67,7 @@ export function distribution(name: string, value: number, data?: MetricData): vo
6667
* @experimental This API is experimental and might having breaking changes in the future.
6768
*/
6869
export function set(name: string, value: number, data?: MetricData): void {
69-
addToMetricsAggregator('s', name, value, data);
70+
addToMetricsAggregator(SET_METRIC_TYPE, name, value, data);
7071
}
7172

7273
/**
@@ -75,5 +76,5 @@ export function set(name: string, value: number, data?: MetricData): void {
7576
* @experimental This API is experimental and might having breaking changes in the future.
7677
*/
7778
export function gauge(name: string, value: number, data?: MetricData): void {
78-
addToMetricsAggregator('s', name, value, data);
79+
addToMetricsAggregator(GAUGE_METRIC_TYPE, name, value, data);
7980
}

packages/core/src/metrics/instance.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { COUNTER_METRIC_TYPE, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, SET_METRIC_TYPE } from './constants';
2+
13
interface MetricInstance {
24
add(value: number): void;
35
toString(): string;
@@ -99,8 +101,8 @@ export class SetMetric implements MetricInstance {
99101
export type Metric = CounterMetric | GaugeMetric | DistributionMetric | SetMetric;
100102

101103
export const METRIC_MAP = {
102-
c: CounterMetric,
103-
g: GaugeMetric,
104-
d: DistributionMetric,
105-
s: SetMetric,
104+
[COUNTER_METRIC_TYPE]: CounterMetric,
105+
[GAUGE_METRIC_TYPE]: GaugeMetric,
106+
[DISTRIBUTION_METRIC_TYPE]: DistributionMetric,
107+
[SET_METRIC_TYPE]: SetMetric,
106108
};

packages/core/src/metrics/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { MeasurementUnit, Primitive } from '@sentry/types';
22
import type { COUNTER_METRIC_TYPE, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, SET_METRIC_TYPE } from './constants';
3-
import { Metric } from './instance';
43

54
export type MetricType =
65
| typeof COUNTER_METRIC_TYPE

0 commit comments

Comments
 (0)