Skip to content

Commit 0e474f6

Browse files
authored
feat: Deprecate metrics API (#14157)
The metrics beta has ended, so we are deprecating the metrics API. 🫡
1 parent 7f7f12e commit 0e474f6

File tree

25 files changed

+64
-30
lines changed

25 files changed

+64
-30
lines changed

.size-limit.js

-14
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

+1
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/astro/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ export declare const continueTrace: typeof clientSdk.continueTrace;
3232

3333
export declare const Span: clientSdk.Span;
3434

35+
// eslint-disable-next-line deprecation/deprecation
3536
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk;
3637
export default sentryAstro;

packages/aws-serverless/src/index.ts

+1
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

+15-5
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

+1
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

+1
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

+2
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

+1
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

+16-5
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

+12-5
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,

packages/core/test/lib/metrics/timing.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable deprecation/deprecation */
12
import { getCurrentScope, getIsolationScope, setCurrentClient } from '../../../src';
23
import { MetricsAggregator } from '../../../src/metrics/aggregator';
34
import { metrics as metricsCore } from '../../../src/metrics/exports';

packages/deno/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export {
6262
startSpanManual,
6363
startNewTrace,
6464
suppressTracing,
65+
// eslint-disable-next-line deprecation/deprecation
6566
metricsDefault as metrics,
6667
inboundFiltersIntegration,
6768
linkedErrorsIntegration,

packages/deno/src/sdk.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/consistent-type-imports */
21
import type { ServerRuntimeClientOptions } from '@sentry/core';
32
import {
43
dedupeIntegration,

packages/google-cloud-serverless/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export {
7474
continueTrace,
7575
getAutoPerformanceIntegrations,
7676
cron,
77+
// eslint-disable-next-line deprecation/deprecation
7778
metrics,
7879
parameterize,
7980
SEMANTIC_ATTRIBUTE_SENTRY_OP,

packages/nextjs/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export declare const createReduxEnhancer: typeof clientSdk.createReduxEnhancer;
3636
export declare const showReportDialog: typeof clientSdk.showReportDialog;
3737
export declare const withErrorBoundary: typeof clientSdk.withErrorBoundary;
3838

39+
// eslint-disable-next-line deprecation/deprecation
3940
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;
4041

4142
export { withSentryConfig } from './config';

packages/node/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export {
116116
extraErrorDataIntegration,
117117
rewriteFramesIntegration,
118118
sessionTimingIntegration,
119+
// eslint-disable-next-line deprecation/deprecation
119120
metricsDefault as metrics,
120121
startSession,
121122
captureSession,

packages/nuxt/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export declare const contextLinesIntegration: typeof clientSdk.contextLinesInteg
1515
export declare const getDefaultIntegrations: (options: Options) => Integration[];
1616
export declare const defaultStackParser: StackParser;
1717
export declare const continueTrace: typeof clientSdk.continueTrace;
18+
// eslint-disable-next-line deprecation/deprecation
1819
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;

packages/remix/src/index.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export {
7474
linkedErrorsIntegration,
7575
localVariablesIntegration,
7676
makeNodeTransport,
77+
// eslint-disable-next-line deprecation/deprecation
7778
metrics,
7879
modulesIntegration,
7980
mongoIntegration,

packages/remix/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ export const close = runtime === 'client' ? clientSdk.close : serverSdk.close;
3939
export const flush = runtime === 'client' ? clientSdk.flush : serverSdk.flush;
4040
export const lastEventId = runtime === 'client' ? clientSdk.lastEventId : serverSdk.lastEventId;
4141

42+
// eslint-disable-next-line deprecation/deprecation
4243
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;

packages/solidstart/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ export declare function lastEventId(): string | undefined;
2727

2828
export declare const continueTrace: typeof clientSdk.continueTrace;
2929

30+
// eslint-disable-next-line deprecation/deprecation
3031
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;

packages/solidstart/src/server/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export {
6565
linkedErrorsIntegration,
6666
localVariablesIntegration,
6767
makeNodeTransport,
68+
// eslint-disable-next-line deprecation/deprecation
6869
metrics,
6970
modulesIntegration,
7071
mongoIntegration,

packages/sveltekit/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export declare function lastEventId(): string | undefined;
5252

5353
export declare const continueTrace: typeof clientSdk.continueTrace;
5454

55+
// eslint-disable-next-line deprecation/deprecation
5556
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;
5657

5758
export declare function trackComponent(options: clientSdk.TrackingOptions): ReturnType<typeof clientSdk.trackComponent>;

packages/sveltekit/src/server/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export {
6767
linkedErrorsIntegration,
6868
localVariablesIntegration,
6969
makeNodeTransport,
70+
// eslint-disable-next-line deprecation/deprecation
7071
metrics,
7172
modulesIntegration,
7273
mongoIntegration,

packages/vercel-edge/src/index.ts

+1
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,

0 commit comments

Comments
 (0)