-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Metrics Product Docs #15375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metrics Product Docs #15375
Changes from all commits
3f3e06c
0404e6c
d7ed0e6
54f1769
cab277e
ce3ac54
52942b7
0ef2cca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,380 @@ | ||
| --- | ||
| title: Set Up | ||
| sidebar_order: 0 | ||
| description: "Learn how to set up Sentry's Metrics feature using our supported SDKs." | ||
| --- | ||
|
|
||
| <Alert level="info"> | ||
| Metrics is currently in Open Beta for non-Enterprise plans running the JavaScript or Python SDKs. If you'd like access, please comment with your org slug on [this GitHub discussion](https://github.com/getsentry/sentry/discussions/102275) or contact us at feedback-metrics@sentry.io. | ||
| </Alert> | ||
|
|
||
| To set up Sentry Metrics, use the links below for supported SDKs. After it's been set up, you'll be able to send counters, gauges, and distributions from your code and view them in Sentry with direct links to related traces. | ||
|
|
||
| ## Supported SDKs | ||
|
|
||
| ### JavaScript | ||
|
|
||
| Minimum SDK version: **10.20.0** | ||
|
|
||
| - <LinkWithPlatformIcon | ||
| platform="javascript.browser" | ||
| label="Browser JavaScript" | ||
| url="/platforms/javascript/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.angular" | ||
| label="Angular" | ||
| url="/platforms/javascript/guides/angular/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.astro" | ||
| label="Astro" | ||
| url="/platforms/javascript/guides/astro/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.aws-lambda" | ||
| label="AWS Lambda" | ||
| url="/platforms/javascript/guides/aws-lambda/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.azure-functions" | ||
| label="Azure Functions" | ||
| url="/platforms/javascript/guides/azure-functions/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.bun" | ||
| label="Bun" | ||
| url="/platforms/javascript/guides/bun/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.cloudflare" | ||
| label="Cloudflare" | ||
| url="/platforms/javascript/guides/cloudflare/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.connect" | ||
| label="Connect" | ||
| url="/platforms/javascript/guides/connect/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.electron" | ||
| label="Electron" | ||
| url="/platforms/javascript/guides/electron/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.ember" | ||
| label="Ember" | ||
| url="/platforms/javascript/guides/ember/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.express" | ||
| label="Express" | ||
| url="/platforms/javascript/guides/express/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.fastify" | ||
| label="Fastify" | ||
| url="/platforms/javascript/guides/fastify/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.gatsby" | ||
| label="Gatsby" | ||
| url="/platforms/javascript/guides/gatsby/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.gcp-functions" | ||
| label="Google Cloud Functions" | ||
| url="/platforms/javascript/guides/gcp-functions/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.hapi" | ||
| label="Hapi" | ||
| url="/platforms/javascript/guides/hapi/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.hono" | ||
| label="Hono" | ||
| url="/platforms/javascript/guides/hono/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.koa" | ||
| label="Koa" | ||
| url="/platforms/javascript/guides/koa/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.nestjs" | ||
| label="Nest.js" | ||
| url="/platforms/javascript/guides/nestjs/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.node" | ||
| label="Node.js" | ||
| url="/platforms/javascript/guides/node/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.nextjs" | ||
| label="Next.js" | ||
| url="/platforms/javascript/guides/nextjs/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.nuxt" | ||
| label="Nuxt" | ||
| url="/platforms/javascript/guides/nuxt/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.react" | ||
| label="React" | ||
| url="/platforms/javascript/guides/react/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.react-router" | ||
| label="React Router" | ||
| url="/platforms/javascript/guides/react-router/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.remix" | ||
| label="Remix" | ||
| url="/platforms/javascript/guides/remix/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.solid" | ||
| label="Solid" | ||
| url="/platforms/javascript/guides/solid/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.solidstart" | ||
| label="SolidStart" | ||
| url="/platforms/javascript/guides/solidstart/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.svelte" | ||
| label="Svelte" | ||
| url="/platforms/javascript/guides/svelte/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.sveltekit" | ||
| label="SvelteKit" | ||
| url="/platforms/javascript/guides/sveltekit/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.tanstackstart-react" | ||
| label="TanStack Start" | ||
| url="/platforms/javascript/guides/tanstackstart-react/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.vue" | ||
| label="Vue" | ||
| url="/platforms/javascript/guides/vue/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="javascript.wasm" | ||
| label="Wasm" | ||
| url="/platforms/javascript/guides/wasm/metrics/" | ||
| /> | ||
|
|
||
| ### Python | ||
|
|
||
| Minimum SDK version: **2.43.0** | ||
|
|
||
| - <LinkWithPlatformIcon | ||
| platform="python" | ||
| label="Python" | ||
| url="/platforms/python/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.django" | ||
| label="Django" | ||
| url="/platforms/python/guides/django/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.flask" | ||
| label="Flask" | ||
| url="/platforms/python/guides/flask/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.fastapi" | ||
| label="FastAPI" | ||
| url="/platforms/python/guides/fastapi/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.starlette" | ||
| label="Starlette" | ||
| url="/platforms/python/guides/starlette/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.celery" | ||
| label="Celery" | ||
| url="/platforms/python/guides/celery/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.aws-lambda" | ||
| label="AWS Lambda" | ||
| url="/platforms/python/guides/aws-lambda/metrics/" | ||
| /> | ||
| - <LinkWithPlatformIcon | ||
| platform="python.gcp-functions" | ||
| label="Google Cloud Functions" | ||
| url="/platforms/python/guides/gcp-functions/metrics/" | ||
| /> | ||
|
Comment on lines
+208
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: New getting-started guide links to non-existent JavaScript metrics documentation pages. 🔍 Detailed AnalysisThe new getting-started guide in 💡 Suggested FixCreate the missing JavaScript platform-specific metrics documentation pages or remove/update the links in 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| ## Quick Start Examples | ||
|
|
||
| ### JavaScript Example | ||
|
|
||
| First, enable metrics in your Sentry initialization: | ||
|
|
||
| ```javascript | ||
| import * as Sentry from "@sentry/node"; // or your specific framework | ||
|
|
||
| Sentry.init({ | ||
| dsn: '<your-dsn>', | ||
| _experiments: { | ||
| enableMetrics: true | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| Then use the metrics API to send counters, gauges, and distributions: | ||
|
|
||
| ```javascript | ||
| // Counter — increment a metric (defaults to +1) | ||
| Sentry.metrics.count('checkout.failed', 1, { | ||
| attributes: { | ||
| route: '/checkout', | ||
| tenant: 'acme', | ||
| provider: 'stripe', | ||
| }, | ||
| }); | ||
|
|
||
| // Gauge — set a current value | ||
| Sentry.metrics.gauge('queue.depth', 42, { | ||
| unit: 'items', | ||
| attributes: { | ||
| queue: 'emails', | ||
| region: 'us-east-1', | ||
| }, | ||
| }); | ||
|
|
||
| // Distribution — record numeric values to compute p95, avg, sum, etc. | ||
| Sentry.metrics.distribution('cart.amount_usd', 187.5, { | ||
| unit: 'usd', | ||
| attributes: { | ||
| currency: 'USD', | ||
| tenant: 'acme', | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| Each metric event includes: | ||
| - **name**: The metric identifier | ||
| - **kind**: counter, gauge, or distribution | ||
| - **value**: The numeric value | ||
| - **attributes**: Custom key-value pairs for grouping and filtering | ||
| - **trace_id, span_id**: Automatically attached to link with traces | ||
| - **unit** (optional): Unit of measurement | ||
| - **byte_size** (optional): Size information | ||
|
|
||
| More details: [JavaScript SDK Metrics Discussion](https://github.com/getsentry/sentry-javascript/discussions/18055) | ||
|
|
||
| ### Python Example | ||
|
|
||
| First, enable metrics in your Sentry initialization: | ||
|
|
||
| ```python | ||
| import sentry_sdk | ||
| from sentry_sdk import metrics | ||
|
|
||
| sentry_sdk.init( | ||
| dsn="___PUBLIC_DSN___", | ||
| _experiments={ | ||
| "enable_metrics": True, | ||
| }, | ||
| ) | ||
| ``` | ||
|
|
||
| Then use the metrics API to send counters, gauges, and distributions: | ||
|
|
||
| ```python | ||
| # Counter — increment a metric (defaults to +1) | ||
| metrics.count( | ||
| "checkout.failed", | ||
| 1, | ||
| attributes={"route": "/checkout", "tenant": "acme"} | ||
| ) | ||
|
|
||
| # Gauge — set a current value | ||
| metrics.gauge( | ||
| "queue.depth", | ||
| 42, | ||
| attributes={"queue": "emails"} | ||
| ) | ||
|
|
||
| # Distribution — record numeric values to compute p95, avg, sum, etc. | ||
| metrics.distribution( | ||
| "cart.amount_usd", | ||
| 187.5, | ||
| attributes={"currency": "USD", "tenant": "acme"} | ||
| ) | ||
| ``` | ||
|
|
||
| Each metric event includes: | ||
| - **name**: The metric identifier | ||
| - **kind**: counter, gauge, or distribution | ||
| - **value**: The numeric value | ||
| - **attributes**: Custom key-value pairs for grouping and filtering | ||
| - **trace_id, span_id**: Automatically attached to link with traces | ||
| - **unit** (optional): Unit of measurement | ||
|
|
||
| More details: [Python SDK Metrics Discussion](https://github.com/getsentry/sentry-python/discussions/5042) | ||
|
|
||
| ## Best Practices | ||
|
|
||
| ### Naming Conventions | ||
|
|
||
| Use descriptive, dot-separated names that indicate the metric's purpose: | ||
|
|
||
| - **Good**: `checkout.failed`, `email.sent`, `queue.depth` | ||
| - **Avoid**: `metric1`, `counter`, `x` | ||
|
|
||
| ### Attributes | ||
|
|
||
| Add attributes for any dimension you want to group or filter by: | ||
|
|
||
| ```javascript | ||
| Sentry.metrics.count('api.request', 1, { | ||
| attributes: { | ||
| endpoint: '/users', | ||
| method: 'GET', | ||
| status: '200', | ||
| region: 'us-west', | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| This allows you to query metrics like: | ||
| - `sum(api.request)` grouped by `endpoint` | ||
| - `sum(api.request)` where `status:500` | ||
| - `sum(api.request)` grouped by `region` where `method:POST` | ||
|
|
||
| ### Units | ||
|
|
||
| Always specify units for clarity: | ||
|
|
||
| - Time: `ms`, `seconds` | ||
| - Size: `bytes`, `kb`, `mb` | ||
| - Currency: `usd`, `eur` | ||
| - Count: `items`, `requests`, `users` | ||
|
|
||
| ### When to Instrument | ||
|
|
||
| Add metrics at key decision points in your code: | ||
|
|
||
| - **Before/after critical operations**: Track success and failure rates | ||
| - **At service boundaries**: Monitor external API calls, database queries | ||
| - **Business logic**: Capture important business events | ||
| - **Resource usage**: Track queue depths, connection pools, cache sizes | ||
|
|
||
| ## Upcoming SDKs | ||
|
|
||
| We're actively working on adding Metrics functionality to additional SDKs. If you don't see your platform listed above, please reach out to us on [GitHub](https://github.com/getsentry/sentry/discussions/102275) or contact us at [feedback-metrics@sentry.io](mailto:feedback-metrics@sentry.io). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug
The documentation links to
/platforms/javascript/metrics/and/platforms/javascript/guides/:guide/metrics/paths, but these URLs are already redirected in redirects.js (lines 1080-1086) to/platforms/javascript/tracing/span-metrics/which is a different feature. This means all the platform-specific metrics links (lines 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97, 102, 107, 112, 117, 122, 127, 132, 137, 142, 147, 152, 157, 162, 167, 172) will redirect users to span-metrics documentation instead of the intended Metrics feature documentation, breaking the documentation flow.