Skip to content

Commit 2f99bdf

Browse files
committed
feat: Deprecate metrics API
1 parent 984a6bd commit 2f99bdf

File tree

22 files changed

+61
-30
lines changed

22 files changed

+61
-30
lines changed

.size-limit.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,6 @@ module.exports = [
8888
gzip: true,
8989
limit: '95 KB',
9090
},
91-
{
92-
name: '@sentry/browser (incl. Tracing, Replay, Feedback, metrics)',
93-
path: 'packages/browser/build/npm/esm/index.js',
94-
import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration', 'metrics'),
95-
gzip: true,
96-
limit: '100 KB',
97-
},
98-
{
99-
name: '@sentry/browser (incl. metrics)',
100-
path: 'packages/browser/build/npm/esm/index.js',
101-
import: createImport('init', 'metrics'),
102-
gzip: true,
103-
limit: '30 KB',
104-
},
10591
{
10692
name: '@sentry/browser (incl. Feedback)',
10793
path: 'packages/browser/build/npm/esm/index.js',

packages/astro/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export {
7474
localVariablesIntegration,
7575
lruMemoizerIntegration,
7676
makeNodeTransport,
77+
// eslint-disable-next-line deprecation/deprecation
7778
metrics,
7879
modulesIntegration,
7980
mongoIntegration,

packages/aws-serverless/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export {
7373
continueTrace,
7474
getAutoPerformanceIntegrations,
7575
cron,
76+
// eslint-disable-next-line deprecation/deprecation
7677
metrics,
7778
parameterize,
7879
SEMANTIC_ATTRIBUTE_SENTRY_OP,

packages/browser/src/metrics.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,40 @@ import type { DurationUnit, MetricData, Metrics } from '@sentry/types';
44
/**
55
* Adds a value to a counter metric
66
*
7-
* @experimental This API is experimental and might have breaking changes in the future.
7+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
88
*/
99
function increment(name: string, value: number = 1, data?: MetricData): void {
10+
// eslint-disable-next-line deprecation/deprecation
1011
metricsCore.increment(BrowserMetricsAggregator, name, value, data);
1112
}
1213

1314
/**
1415
* Adds a value to a distribution metric
1516
*
16-
* @experimental This API is experimental and might have breaking changes in the future.
17+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
1718
*/
1819
function distribution(name: string, value: number, data?: MetricData): void {
20+
// eslint-disable-next-line deprecation/deprecation
1921
metricsCore.distribution(BrowserMetricsAggregator, name, value, data);
2022
}
2123

2224
/**
2325
* Adds a value to a set metric. Value must be a string or integer.
2426
*
25-
* @experimental This API is experimental and might have breaking changes in the future.
27+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
2628
*/
2729
function set(name: string, value: number | string, data?: MetricData): void {
30+
// eslint-disable-next-line deprecation/deprecation
2831
metricsCore.set(BrowserMetricsAggregator, name, value, data);
2932
}
3033

3134
/**
3235
* Adds a value to a gauge metric
3336
*
34-
* @experimental This API is experimental and might have breaking changes in the future.
37+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
3538
*/
3639
function gauge(name: string, value: number, data?: MetricData): void {
40+
// eslint-disable-next-line deprecation/deprecation
3741
metricsCore.gauge(BrowserMetricsAggregator, name, value, data);
3842
}
3943

@@ -44,7 +48,7 @@ function gauge(name: string, value: number, data?: MetricData): void {
4448
* You can either directly capture a numeric `value`, or wrap a callback function in `timing`.
4549
* In the latter case, the duration of the callback execution will be captured as a span & a metric.
4650
*
47-
* @experimental This API is experimental and might have breaking changes in the future.
51+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
4852
*/
4953
function timing(name: string, value: number, unit?: DurationUnit, data?: Omit<MetricData, 'unit'>): void;
5054
function timing<T>(name: string, callback: () => T, unit?: DurationUnit, data?: Omit<MetricData, 'unit'>): T;
@@ -54,9 +58,15 @@ function timing<T = void>(
5458
unit: DurationUnit = 'second',
5559
data?: Omit<MetricData, 'unit'>,
5660
): T | void {
61+
// eslint-disable-next-line deprecation/deprecation
5762
return metricsCore.timing(BrowserMetricsAggregator, name, value, unit, data);
5863
}
5964

65+
/**
66+
* The metrics API is used to capture custom metrics in Sentry.
67+
*
68+
* @deprecated The Sentry metrics beta has ended. This export will be removed in a future release.
69+
*/
6070
export const metrics: Metrics = {
6171
increment,
6272
distribution,

packages/bun/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export {
9494
continueTrace,
9595
getAutoPerformanceIntegrations,
9696
cron,
97+
// eslint-disable-next-line deprecation/deprecation
9798
metrics,
9899
parameterize,
99100
SEMANTIC_ATTRIBUTE_SENTRY_OP,

packages/cloudflare/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export {
6565
withActiveSpan,
6666
getSpanDescendants,
6767
continueTrace,
68+
// eslint-disable-next-line deprecation/deprecation
6869
metrics,
6970
functionToStringIntegration,
7071
inboundFiltersIntegration,

packages/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ export { rewriteFramesIntegration } from './integrations/rewriteframes';
9999
export { sessionTimingIntegration } from './integrations/sessiontiming';
100100
export { zodErrorsIntegration } from './integrations/zoderrors';
101101
export { thirdPartyErrorFilterIntegration } from './integrations/third-party-errors-filter';
102+
// eslint-disable-next-line deprecation/deprecation
102103
export { metrics } from './metrics/exports';
103104
export { profiler } from './profiling';
104105
export type { MetricData } from '@sentry/types';
106+
// eslint-disable-next-line deprecation/deprecation
105107
export { metricsDefault } from './metrics/exports-default';
106108
export { BrowserMetricsAggregator } from './metrics/browser-aggregator';
107109
export { getMetricSummaryJsonForSpan } from './metrics/metric-summary';

packages/core/src/metrics/aggregator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class MetricsAggregator implements MetricsAggregatorBase {
4040
this._buckets = new Map();
4141
this._bucketsTotalWeight = 0;
4242

43+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4344
this._interval = setInterval(() => this._flush(), DEFAULT_FLUSH_INTERVAL) as any;
4445
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4546
if (this._interval.unref) {

packages/core/src/metrics/exports-default.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,40 @@ import { metrics as metricsCore } from './exports';
1111
/**
1212
* Adds a value to a counter metric
1313
*
14-
* @experimental This API is experimental and might have breaking changes in the future.
14+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
1515
*/
1616
function increment(name: string, value: number = 1, data?: MetricData): void {
17+
// eslint-disable-next-line deprecation/deprecation
1718
metricsCore.increment(MetricsAggregator, name, value, data);
1819
}
1920

2021
/**
2122
* Adds a value to a distribution metric
2223
*
23-
* @experimental This API is experimental and might have breaking changes in the future.
24+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
2425
*/
2526
function distribution(name: string, value: number, data?: MetricData): void {
27+
// eslint-disable-next-line deprecation/deprecation
2628
metricsCore.distribution(MetricsAggregator, name, value, data);
2729
}
2830

2931
/**
3032
* Adds a value to a set metric. Value must be a string or integer.
3133
*
32-
* @experimental This API is experimental and might have breaking changes in the future.
34+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
3335
*/
3436
function set(name: string, value: number | string, data?: MetricData): void {
37+
// eslint-disable-next-line deprecation/deprecation
3538
metricsCore.set(MetricsAggregator, name, value, data);
3639
}
3740

3841
/**
3942
* Adds a value to a gauge metric
4043
*
41-
* @experimental This API is experimental and might have breaking changes in the future.
44+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
4245
*/
4346
function gauge(name: string, value: number, data?: MetricData): void {
47+
// eslint-disable-next-line deprecation/deprecation
4448
metricsCore.gauge(MetricsAggregator, name, value, data);
4549
}
4650

@@ -51,7 +55,7 @@ function gauge(name: string, value: number, data?: MetricData): void {
5155
* You can either directly capture a numeric `value`, or wrap a callback function in `timing`.
5256
* In the latter case, the duration of the callback execution will be captured as a span & a metric.
5357
*
54-
* @experimental This API is experimental and might have breaking changes in the future.
58+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
5559
*/
5660
function timing(name: string, value: number, unit?: DurationUnit, data?: Omit<MetricData, 'unit'>): void;
5761
function timing<T>(name: string, callback: () => T, unit?: DurationUnit, data?: Omit<MetricData, 'unit'>): T;
@@ -61,16 +65,23 @@ function timing<T = void>(
6165
unit: DurationUnit = 'second',
6266
data?: Omit<MetricData, 'unit'>,
6367
): T | void {
68+
// eslint-disable-next-line deprecation/deprecation
6469
return metricsCore.timing(MetricsAggregator, name, value, unit, data);
6570
}
6671

6772
/**
6873
* Returns the metrics aggregator for a given client.
6974
*/
7075
function getMetricsAggregatorForClient(client: Client): MetricsAggregatorInterface {
76+
// eslint-disable-next-line deprecation/deprecation
7177
return metricsCore.getMetricsAggregatorForClient(client, MetricsAggregator);
7278
}
7379

80+
/**
81+
* The metrics API is used to capture custom metrics in Sentry.
82+
*
83+
* @deprecated The Sentry metrics beta has ended. This export will be removed in a future release.
84+
*/
7485
export const metricsDefault: Metrics & {
7586
getMetricsAggregatorForClient: typeof getMetricsAggregatorForClient;
7687
} = {

packages/core/src/metrics/exports.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function addToMetricsAggregator(
7878
/**
7979
* Adds a value to a counter metric
8080
*
81-
* @experimental This API is experimental and might have breaking changes in the future.
81+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
8282
*/
8383
function increment(aggregator: MetricsAggregatorConstructor, name: string, value: number = 1, data?: MetricData): void {
8484
addToMetricsAggregator(aggregator, COUNTER_METRIC_TYPE, name, ensureNumber(value), data);
@@ -87,7 +87,7 @@ function increment(aggregator: MetricsAggregatorConstructor, name: string, value
8787
/**
8888
* Adds a value to a distribution metric
8989
*
90-
* @experimental This API is experimental and might have breaking changes in the future.
90+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
9191
*/
9292
function distribution(aggregator: MetricsAggregatorConstructor, name: string, value: number, data?: MetricData): void {
9393
addToMetricsAggregator(aggregator, DISTRIBUTION_METRIC_TYPE, name, ensureNumber(value), data);
@@ -100,7 +100,7 @@ function distribution(aggregator: MetricsAggregatorConstructor, name: string, va
100100
* You can either directly capture a numeric `value`, or wrap a callback function in `timing`.
101101
* In the latter case, the duration of the callback execution will be captured as a span & a metric.
102102
*
103-
* @experimental This API is experimental and might have breaking changes in the future.
103+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
104104
*/
105105
function timing<T = void>(
106106
aggregator: MetricsAggregatorConstructor,
@@ -129,6 +129,7 @@ function timing<T = void>(
129129
() => {
130130
const endTime = timestampInSeconds();
131131
const timeDiff = endTime - startTime;
132+
// eslint-disable-next-line deprecation/deprecation
132133
distribution(aggregator, name, timeDiff, { ...data, unit: 'second' });
133134
span.end(endTime);
134135
},
@@ -138,13 +139,14 @@ function timing<T = void>(
138139
}
139140

140141
// value form
142+
// eslint-disable-next-line deprecation/deprecation
141143
distribution(aggregator, name, value, { ...data, unit });
142144
}
143145

144146
/**
145147
* Adds a value to a set metric. Value must be a string or integer.
146148
*
147-
* @experimental This API is experimental and might have breaking changes in the future.
149+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
148150
*/
149151
function set(aggregator: MetricsAggregatorConstructor, name: string, value: number | string, data?: MetricData): void {
150152
addToMetricsAggregator(aggregator, SET_METRIC_TYPE, name, value, data);
@@ -153,12 +155,17 @@ function set(aggregator: MetricsAggregatorConstructor, name: string, value: numb
153155
/**
154156
* Adds a value to a gauge metric
155157
*
156-
* @experimental This API is experimental and might have breaking changes in the future.
158+
* @deprecated The Sentry metrics beta has ended. This method will be removed in a future release.
157159
*/
158160
function gauge(aggregator: MetricsAggregatorConstructor, name: string, value: number, data?: MetricData): void {
159161
addToMetricsAggregator(aggregator, GAUGE_METRIC_TYPE, name, ensureNumber(value), data);
160162
}
161163

164+
/**
165+
* The metrics API is used to capture custom metrics in Sentry.
166+
*
167+
* @deprecated The Sentry metrics beta has ended. This export will be removed in a future release.
168+
*/
162169
export const metrics = {
163170
increment,
164171
distribution,

0 commit comments

Comments
 (0)