-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathmetrics.ts
76 lines (70 loc) · 2.67 KB
/
metrics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { BrowserMetricsAggregator, metrics as metricsCore } from '@sentry/core';
import type { DurationUnit, MetricData, Metrics } from '@sentry/types';
/**
* Adds a value to a counter metric
*
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
*/
function increment(name: string, value: number = 1, data?: MetricData): void {
// eslint-disable-next-line deprecation/deprecation
metricsCore.increment(BrowserMetricsAggregator, name, value, data);
}
/**
* Adds a value to a distribution metric
*
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
*/
function distribution(name: string, value: number, data?: MetricData): void {
// eslint-disable-next-line deprecation/deprecation
metricsCore.distribution(BrowserMetricsAggregator, name, value, data);
}
/**
* Adds a value to a set metric. Value must be a string or integer.
*
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
*/
function set(name: string, value: number | string, data?: MetricData): void {
// eslint-disable-next-line deprecation/deprecation
metricsCore.set(BrowserMetricsAggregator, name, value, data);
}
/**
* Adds a value to a gauge metric
*
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
*/
function gauge(name: string, value: number, data?: MetricData): void {
// eslint-disable-next-line deprecation/deprecation
metricsCore.gauge(BrowserMetricsAggregator, name, value, data);
}
/**
* Adds a timing metric.
* The metric is added as a distribution metric.
*
* You can either directly capture a numeric `value`, or wrap a callback function in `timing`.
* In the latter case, the duration of the callback execution will be captured as a span & a metric.
*
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
*/
function timing(name: string, value: number, unit?: DurationUnit, data?: Omit<MetricData, 'unit'>): void;
function timing<T>(name: string, callback: () => T, unit?: DurationUnit, data?: Omit<MetricData, 'unit'>): T;
function timing<T = void>(
name: string,
value: number | (() => T),
unit: DurationUnit = 'second',
data?: Omit<MetricData, 'unit'>,
): T | void {
// eslint-disable-next-line deprecation/deprecation
return metricsCore.timing(BrowserMetricsAggregator, name, value, unit, data);
}
/**
* The metrics API is used to capture custom metrics in Sentry.
*
* @deprecated The Sentry metrics beta has ended. This export will be removed in a future release.
*/
export const metrics: Metrics = {
increment,
distribution,
set,
gauge,
timing,
};