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
7 changes: 0 additions & 7 deletions docs/platforms/javascript/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -805,13 +805,6 @@ This function is called with a log object, and can return a modified log object,
are set.
</PlatformSection>

<SdkOption name="enableMetrics" type='boolean' defaultValue='true'>

Set this option to `false` to disable metric capturing in Sentry (enabled by default).
Only when this option is enabled will the `metrics` APIs actually send metrics to Sentry.

</SdkOption>

<SdkOption name="beforeSendMetric" type='(metric: Metric) => Metric | null'>

This function is called with a metric object, and can return a modified metric object, or `null` to skip sending this metric to Sentry.
Expand Down
11 changes: 8 additions & 3 deletions platform-includes/metrics/options/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ Sentry.init({

### Disable Metrics

Set `enableMetrics: false` to disable metrics collection entirely.
Metrics are only captured when you call `Sentry.metrics.*`, so there is no option to turn them on or off. To stop sending metrics without removing those calls, return `null` from `beforeSendMetric`.

<Alert>
On SDK versions below `11.0.0`, set `enableMetrics: false` in your
`Sentry.init` to disable metrics instead.
</Alert>

### Flush Metrics

Expand All @@ -47,10 +52,10 @@ Metrics are buffered and sent periodically. Use this snippet to flush immediatel
<SplitSectionCode>

```javascript
// Disable metrics
// Drop all metrics
Sentry.init({
dsn: "___PUBLIC_DSN___",
enableMetrics: false,
beforeSendMetric: () => null,
});

// Flush all pending metrics
Expand Down
6 changes: 6 additions & 0 deletions platform-includes/metrics/requirements/javascript.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Metrics are supported in all Sentry JavaScript SDKs version `10.25.0` and above.

<PlatformLink to="/">Make sure you have the SDK set up</PlatformLink> before proceeding.

<PlatformSection supported={["javascript"]}>

Metrics are also supported via [CDN bundles and the Loader Script](/platforms/javascript/install/loader/). Use a bundle that includes metrics, such as `bundle.logs.metrics.min.js`. On other bundles, `Sentry.metrics.*` calls are a no-op that only warns when `debug` is enabled.

</PlatformSection>
2 changes: 1 addition & 1 deletion platform-includes/metrics/usage/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| `gauge` | Current values (queue depth, connections) |
| `distribution` | Value ranges (response times, payload sizes) |

No setup required beyond SDK initialization.
No setup required beyond SDK initialization. Metrics are captured whenever you call `Sentry.metrics.*`.

</SplitSectionText>
<SplitSectionCode>
Expand Down
Loading