Title: Using Sentry breadcrumbs and tags alongside OpenTelemetry isn't working correctly · Issue #7538 · getsentry/sentry-javascript · GitHub
Open Graph Title: Using Sentry breadcrumbs and tags alongside OpenTelemetry isn't working correctly · Issue #7538 · getsentry/sentry-javascript
X Title: Using Sentry breadcrumbs and tags alongside OpenTelemetry isn't working correctly · Issue #7538 · 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/7538
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using Sentry breadcrumbs and tags alongside OpenTelemetry isn't working correctly","articleBody":"### Is there an existing issue for this?\r\n\r\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\r\n- [X] I have reviewed the documentation https://docs.sentry.io/\r\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\r\n\r\n### How do you use Sentry?\r\n\r\nSentry Saas (sentry.io)\r\n\r\n### Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. `bundle.tracing.min.js`) in your SDK setup.\r\n\r\n@sentry/node\r\n\r\n### SDK Version\r\n\r\n7.43.0\r\n\r\n### Framework Version\r\n\r\n_No response_\r\n\r\n### Link to Sentry event\r\n\r\nhttps://paragraph.sentry.io/performance/node:08b586a3e77243548a96ac02db296d0f/?project=6606495&query=&statsPeriod=5m&transaction=POST+%2Fmetrics%2Fpost-track\r\n\r\n### SDK Setup\r\n\r\n\r\n```js\r\nSentry.init({\r\n dsn: \"MY_DSN\",\r\n\r\n enabled: isProduction,\r\n\r\n instrumenter: \"otel\",\r\n\r\n release: process.env.COMMIT,\r\n environment: process.env.FLY_APP_NAME || \"development\",\r\n\r\n\r\n tracesSampler: (samplingContext) => {\r\n // Drop transactions for routes we don't care about\r\n for (const route of SENTRY_IGNORED_ROUTES) {\r\n if (samplingContext?.request?.url?.endsWith(route)) return 0\r\n }\r\n\r\n // Drop transactions for non-production environments. (We still care about errors\r\n // on non-production environments, but we don't need to see all the transactions.)\r\n if (process.env.FLY_APP_NAME !== \"paragraph-master\") return 0\r\n\r\n return TRACE_SAMPLE_PERCENTAGE\r\n },\r\n\r\n profilesSampleRate: 1.0, // Profiling sample rate is relative to tracesSampleRate\r\n\r\n beforeSend: (event) => {\r\n if (!event.request?.data) return event\r\n\r\n const size = JSON.stringify(event.request?.data || \"\").length\r\n\r\n // Arbitrarily cut off massive payloads. Sentry silently drops events that are too large,\r\n // so trim them.\r\n // See https://github.com/getsentry/sentry-javascript/issues/3036#issuecomment-1066491190\r\n if (size > 500000) {\r\n event.request = event.request?.data?.slice(0, 500000)\r\n }\r\n\r\n return event\r\n },\r\n\r\n integrations: [new ProfilingIntegration()],\r\n})\r\n\r\n// Only load OpenTelemetry in production,\r\n// so we aren't spamming Sentry with test data.\r\nif (isProduction) {\r\n const sdk = new opentelemetry.NodeSDK({\r\n /*\r\n sampler: new opentelemetry.tracing.TraceIdRatioBasedSampler(\r\n TRACE_SAMPLE_PERCENTAGE\r\n ),\r\n */\r\n // Existing config\r\n traceExporter: new OTLPTraceExporter(),\r\n instrumentations: [\r\n new HttpInstrumentation({\r\n ignoreIncomingRequestHook(req) {\r\n for (const route of SENTRY_IGNORED_ROUTES) {\r\n if (req.url.endsWith(route)) {\r\n return true\r\n }\r\n }\r\n return false\r\n },\r\n }),\r\n\r\n new ExpressInstrumentation(),\r\n new GrpcInstrumentation({\r\n ignoreGrpcMethods: [\r\n \"google.logging.v2.LoggingServiceV2/WriteLogEntries\",\r\n new RegExp(\".*google.logging.*\"),\r\n new RegExp(\".*WriteLogEntries*\"),\r\n (name) => {\r\n return name.startsWith(\"google.logging\")\r\n },\r\n ],\r\n }),\r\n ],\r\n\r\n // Sentry config\r\n spanProcessor: new SentrySpanProcessor(),\r\n })\r\n\r\n otelApi.propagation.setGlobalPropagator(new SentryPropagator())\r\n\r\n sdk.start()\r\n}\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\nI've been happily using Sentry for some time. using @sentry/node with Express.\r\n\r\nToday we switched from using Sentry tracing to OpenTelemetry-based tracing, using @sentry/opentelemetry-node. Transactions are getting logged fine, but it appears that breadcrumbs and tags are not correctly added to the transaction.\r\n\r\nViewing any Sentry event (eg the one linked above) has tags from what seems like other requests. Additionally, the breadcrumbs also don't correspond to this request.\r\n\r\nThere's a chance I'm doing something incorrect in Sentry.init() above. For example, I don't need to use any Sentry tracing functionality now that I have OpenTelemtry tracing working, right? The documentation [here](https://docs.sentry.io/platforms/node/performance/instrumentation/opentelemetry/) is a bit light so it's unclear to me.\r\n\r\nAdditionally, I'm getting an exception on startup (see logs below).\r\n\r\n### Expected Result\r\n\r\nI'd expect to be able to use `Sentry.addBreadcrumb` and `Sentry.addTag` throughout the codebase, and it would add the breadcrumb and tag to the current transaction/span created by Opentelemetry.\r\n\r\n### Actual Result\r\n\r\nI get this non-fatal exception on startup:\r\n```sh\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info]Error: @opentelemetry/api: Attempted duplicate registration of API: propagation\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at registerGlobal (/workspace/node_modules/@opentelemetry/api/build/src/internal/global-utils.js:32:21)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at PropagationAPI.setGlobalPropagator (/workspace/node_modules/@opentelemetry/api/build/src/api/propagation.js:52:50)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at NodeTracerProvider.register (/workspace/node_modules/@opentelemetry/sdk-trace-base/build/src/BasicTracerProvider.js:100:31)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at NodeTracerProvider.register (/workspace/node_modules/@opentelemetry/sdk-trace-node/build/src/NodeTracerProvider.js:43:15)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at NodeSDK.start (/workspace/node_modules/@opentelemetry/sdk-node/build/src/sdk.js:158:24)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at Object.\u003canonymous> (/workspace/packages/api/dist/trace.cjs:127:7)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at Module._compile (node:internal/modules/cjs/loader:1159:14)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at Module.load (node:internal/modules/cjs/loader:1037:32)\r\n2023-03-20T19:21:52Z app[53d5f709] iad [info] at Module._load (node:internal/modules/cjs/loader:878:12)\r\n\r\n```\r\n\r\nIf I replace the NodeSDK init with the following, the error goes away, but I don't know if it's actually using SentryPropagator now:\r\n\r\n```\r\n const sdk = new opentelemetry.NodeSDK({\r\n textMapPropagator: new SentryPropagator(),\r\n... \r\n})\r\n```","author":{"url":"https://github.com/seeARMS","@type":"Person","name":"seeARMS"},"datePublished":"2023-03-20T19:24:31Z","url":"https://github.com/getsentry/sentry-javascript/issues/7538"}
| 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:2ed9abd0-a48d-132c-0fbd-ccf9f3ae21ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BC2:3AF230:67127C:8E5BDF:6B04A414 |
| html-safe-nonce | 95eedd40701ad6645609eefecf6505ad6bddc0bbe226b288ff4e22313aa86213 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkMyOjNBRjIzMDo2NzEyN0M6OEU1QkRGOjZCMDRBNDE0IiwidmlzaXRvcl9pZCI6IjEzOTg1MjE2OTkzMjYyNzI1MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 76a9ebc944b72e5420ecb71212da90f1d5c42f55315207686300176f3bd19a5e |
| hovercard-subject-tag | issue:1632730745 |
| 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/7538/issue_layout |
| twitter:image | https://opengraph.githubassets.com/41a9982247c02eed2f3fd31d42f48834ece92e87a19f71e0c327a45260bb3984/getsentry/sentry-javascript/issues/7538 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/41a9982247c02eed2f3fd31d42f48834ece92e87a19f71e0c327a45260bb3984/getsentry/sentry-javascript/issues/7538 |
| 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 | seeARMS |
| hostname | github.com |
| expected-hostname | github.com |
| None | 188497a0f45a7aa8f7c866faa1950d1a7f8d82b59416adf549b222ad1d1dd19b |
| 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 | 557cfbac6cdb532730c95c90f2cefdc0c4128029 |
| 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