Title: Sentry strips Fastify http.route attribute with OpenTelemetry on metrics · Issue #14180 · getsentry/sentry-javascript · GitHub
Open Graph Title: Sentry strips Fastify http.route attribute with OpenTelemetry on metrics · Issue #14180 · getsentry/sentry-javascript
X Title: Sentry strips Fastify http.route attribute with OpenTelemetry on metrics · Issue #14180 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/14180
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sentry strips Fastify http.route attribute with OpenTelemetry on metrics","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/node\n\n### SDK Version\n\n8.36.0\n\n### Framework Version\n\nFastify 4.28.0\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\nhttps://github.com/nathanscully/otel-sentry-fastify\n\nRepo contains three different versions of Fastify / Sentry / Otel setup\n\n### Steps to Reproduce\n\nClone the repo and run the various start commands against an otel-collector.\n\n### Only OTEL\n\n`pnpm start:otel` will run a standard otel setup, which patches Fastify and emits metrics. In the otel collector you can see the `http.route` metric includes:\n\n```\nMetric #0\nDescriptor:\n -> Name: http.server.duration\n -> Description: Measures the duration of inbound HTTP requests.\n -> Unit: ms\n -> DataType: Histogram\n -> AggregationTemporality: Cumulative\nHistogramDataPoints #0\nData point attributes:\n -> http.scheme: Str(http)\n -> http.method: Str(GET)\n -> net.host.name: Str(localhost)\n -> http.flavor: Str(1.1)\n -> http.status_code: Int(200)\n -> net.host.port: Int(3000)\n -> http.route: Str(/) \u003c----- IMPORTANT\nStartTimestamp: 2024-11-04 22:10:03.643 +0000 UTC\nTimestamp: 2024-11-04 22:11:24.65 +0000 UTC\nCount: 2060\n```\n\n### Sentry Docs Example \n\n`pnpm start:sentry-docs` will run the copy/paste from the Otel Sentry docs. I can't get any metrics to emit to Otel doing it this way. Would love an example if I am doing something wrong here. Note that when I run this I still get the following errors and warnings:\n\n```\n\nSentry Logger [log]: Initializing Sentry: process: 60425, thread: worker-2.\nSentry Logger [error]: You have to set up the SentryPropagator. Without this, the OpenTelemetry & Sentry integration will not work properly.\nSentry Logger [log]: Integration installed: ...\n...\n..\nSentry Logger [log]: Running in ESM mode.\nSentry Logger [error]: You have to set up the SentrySpanProcessor. Without this, the OpenTelemetry & Sentry integration will not work properly.\nSentry Logger [warn]: You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.\n[09:18:32.930] INFO (60425): Server listening at http://0.0.0.0:3000\n\n```\n\nWhich I find strange given that this is straight out of the docs - would be good to understand why its still throwing warnings and errors.\n\n### Sentry + Custom OTEL\n\n`pnpm start:otel-sentry` will run my attempt at getting Sentry to play nice with Otel's NodeSDK. Traces emit ok, but the metrics from fastify have the `http.route` stripped, which is breaking all our reporting:\n\n```\nMetric #0\nDescriptor:\n -> Name: http.server.duration\n -> Description: Measures the duration of inbound HTTP requests.\n -> Unit: ms\n -> DataType: Histogram\n -> AggregationTemporality: Cumulative\nHistogramDataPoints #0\nData point attributes:\n -> http.scheme: Str(http)\n -> http.method: Str(GET)\n -> net.host.name: Str(localhost)\n -> http.flavor: Str(1.1)\n -> http.status_code: Int(200)\n -> net.host.port: Int(3000)\n \u003c--- IMPORTANT no http.route attribute present\nStartTimestamp: 2024-11-04 22:38:01.18 +0000 UTC\nTimestamp: 2024-11-04 22:38:48.472 +0000 UTC\n```\n\n\n\n### Expected Result\n\n### Goal\n\nEmit traces and metrics to a custom otel collector and use Sentry for error handling. If we also need to emit traces to Sentry to make this work, thats fine, but it's my preference not to.\n\n## What is not working\n\nWhen using Sentry + Fastify + a custom Otel setup, Sentry appears to strip the `http.route` from the `http.server.duration` metrics making reporting by endpoint impossible.\n\n### Actual Result\n\n```\nMetric #0\nDescriptor:\n -> Name: http.server.duration\n -> Description: Measures the duration of inbound HTTP requests.\n -> Unit: ms\n -> DataType: Histogram\n -> AggregationTemporality: Cumulative\nHistogramDataPoints #0\nData point attributes:\n -> http.scheme: Str(http)\n -> http.method: Str(GET)\n -> net.host.name: Str(localhost)\n -> http.flavor: Str(1.1)\n -> http.status_code: Int(200)\n -> net.host.port: Int(3000)\n \u003c--- IMPORTANT no http.route attribute present\nStartTimestamp: 2024-11-04 22:38:01.18 +0000 UTC\nTimestamp: 2024-11-04 22:38:48.472 +0000 UTC\n```","author":{"url":"https://github.com/nathanscully","@type":"Person","name":"nathanscully"},"datePublished":"2024-11-04T23:02:21Z","url":"https://github.com/getsentry/sentry-javascript/issues/14180"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7753d136-5419-cbd8-0b07-19762582e876 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB4E:2F12FE:DE8BE9:1271ADF:6B0508BD |
| html-safe-nonce | 447ba286c33330aba4604f54dd53f97665f6f73a21ca7a5c3f111d023010fe84 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjRFOjJGMTJGRTpERThCRTk6MTI3MUFERjo2QjA1MDhCRCIsInZpc2l0b3JfaWQiOiI2Njc0OTQ3NTE5OTE2ODY5ODIxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f976040e2693a1fdb2e637e3b0ea8c90b257455da9d1cb317f362cbea9432e9a |
| hovercard-subject-tag | issue:2634042181 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/14180/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5a9e944d5077651a25491a66cdebffda9c2eee2e60b5a50055380bd42e5459a5/getsentry/sentry-javascript/issues/14180 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5a9e944d5077651a25491a66cdebffda9c2eee2e60b5a50055380bd42e5459a5/getsentry/sentry-javascript/issues/14180 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nathanscully |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width