René's URL Explorer Experiment


Title: Handle delayed OpenTelemetry span finish calls · Issue #5373 · getsentry/sentry-java · GitHub

Open Graph Title: Handle delayed OpenTelemetry span finish calls · Issue #5373 · getsentry/sentry-java

X Title: Handle delayed OpenTelemetry span finish calls · Issue #5373 · getsentry/sentry-java

Description: Problem If a child OpenTelemetry span is finished after its local root span (which Sentry turns into a transaction) and arrives at SentrySpanExporter in a later exporter batch than the root span, the child becomes orphaned and is never s...

Open Graph Description: Problem If a child OpenTelemetry span is finished after its local root span (which Sentry turns into a transaction) and arrives at SentrySpanExporter in a later exporter batch than the root span, t...

X Description: Problem If a child OpenTelemetry span is finished after its local root span (which Sentry turns into a transaction) and arrives at SentrySpanExporter in a later exporter batch than the root span, t...

Opengraph URL: https://github.com/getsentry/sentry-java/issues/5373

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle delayed OpenTelemetry span finish calls","articleBody":"## Problem\n\nIf a child OpenTelemetry span is finished after its local root span (which Sentry turns into a transaction) and arrives at `SentrySpanExporter` in a later exporter batch than the root span, the child becomes orphaned and is never sent to Sentry.\n\nThe root transaction has already been captured by that point, so the late child cannot be appended to it. Today the late child stays in `SentrySpanExporter`'s temporary `finishedSpans` storage as an unset/orphaned span and is eventually dropped after the pending-span timeout.\n\nThis is observable with async producer spans, e.g. Kafka:\n\n- HTTP transaction `GET /kafka/produce` finishes and is exported first.\n- Kafka producer span `queue.publish` may finish later when the Kafka send callback/broker ack completes.\n- If both spans are exported in the same OTel batch, Sentry groups them and the test passes.\n- If the HTTP root is exported in an earlier batch, `queue.publish` arrives too late, remains orphaned, and is dropped.\n\nSo this is currently flaky because it depends on how OpenTelemetry batches ended spans.\n\n## Current behavior\n\n`SentrySpanExporter` only sends completed root nodes:\n\n- local root span -> Sentry transaction\n- child spans under that root -> embedded Sentry spans\n- child whose parent is missing -> retained as pending/unset\n- pending/unset span older than timeout -> dropped\n\nThat means a late `queue.publish` with `parent_span_id` pointing to an already-sent HTTP transaction is not sent at all.\n\n## Expected behavior\n\nLate-finished local child spans should not be silently dropped. Ideally they should still be represented in Sentry, either by giving them a chance to be grouped into the original transaction or by sending them through a model that supports independent span delivery.\n\n## Potential fixes\n\n1. **Wait for span streaming / spans v2**\n   - Architectural fix: send spans independently instead of embedding all children into a transaction event.\n   - A child span finishing after the root could still be sent with trace/span/parent metadata.\n   - This avoids the append-to-already-sent-transaction limitation entirely, but depends on span streaming support for this path.\n\n2. **Debounce root transaction export in `SentrySpanExporter`**\n   - When a completed local root arrives, hold it for a short grace window before creating/sending the Sentry transaction.\n   - If late children arrive during that window, group them into the transaction.\n   - This is a pragmatic improvement and can reduce flakes, but it is timing-based. Children that finish after the grace window can still be missed.\n   - `flush()` and `shutdown()` would need to drain pending roots immediately so short-lived processes do not lose buffered transactions.\n\n3. **Send orphaned late spans as their own transaction**\n   - Keep a bounded cache of sent span ids.\n   - If a late span's parent id is already known as sent, promote the late span to its own transaction and mark it, e.g. `sentry.parent_span_already_sent=true`.\n   - This avoids silent data loss, similar to the Sentry JavaScript OTel exporter behavior.\n   - It does not preserve the original shape (`queue.publish` embedded in `GET /kafka/produce`), but it is better than dropping the span.\n\n## E2E test snippet\n\nThis assertion is useful but currently flaky because it depends on whether OTel exports the HTTP root and Kafka producer span in the same batch. Keeping the snippet here makes it easy to restore once this behavior is fixed.\n\n```kotlin\npackage io.sentry.systemtest\n\nimport io.sentry.systemtest.util.TestHelper\nimport kotlin.test.Test\nimport kotlin.test.assertEquals\nimport org.junit.Before\n\nclass KafkaOtelCoexistenceSystemTest {\n  lateinit var testHelper: TestHelper\n\n  @Before\n  fun setup() {\n    testHelper = TestHelper(\"http://localhost:8080\")\n    testHelper.reset()\n  }\n\n  @Test\n  fun `Sentry Kafka integration is suppressed when OTel is active`() {\n    val restClient = testHelper.restClient\n\n    restClient.produceKafkaMessage(\"otel-coexistence-test\")\n    assertEquals(200, restClient.lastKnownStatusCode)\n\n    testHelper.ensureTransactionReceived { transaction, _ ->\n      transaction.transaction == \"GET /kafka/produce\" &&\n        transaction.sdk?.integrationSet?.contains(\"SpringKafka\") != true &&\n        transaction.spans.any { span ->\n          span.op == \"queue.publish\" &&\n            span.origin == \"auto.opentelemetry\" &&\n            span.data?.get(\"messaging.system\") == \"kafka\"\n        }\n    }\n\n    testHelper.ensureTransactionReceived { transaction, _ ->\n      transaction.contexts.trace?.operation == \"queue.process\" &&\n        transaction.contexts.trace?.origin == \"auto.opentelemetry\" &&\n        transaction.contexts.trace?.data?.get(\"messaging.system\") == \"kafka\" &&\n        transaction.sdk?.integrationSet?.contains(\"SpringKafka\") != true\n    }\n  }\n}\n```\n\n## Related context\n\nThe Kafka producer span can finish after the HTTP request span because Kafka sends are asynchronous. The HTTP handler can return before broker acknowledgement, while OTel Kafka instrumentation ends the producer span from the producer callback.\n\nThe failure has been seen in the Spring Boot Jakarta OpenTelemetry system test:\n\n```bash\npython3 test/system-test-runner.py test \\\n  --module \"sentry-samples-spring-boot-jakarta-opentelemetry\" \\\n  --agent true \\\n  --auto-init \"false\" \\\n  --build \"true\"\n```\n","author":{"url":"https://github.com/adinauer","@type":"Person","name":"adinauer"},"datePublished":"2026-05-06T12:11:59Z","url":"https://github.com/getsentry/sentry-java/issues/5373"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c2b666a5-294b-87fe-5ed6-27fc78175820
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8720:18C3B1:33A6AC:48818D:6B047830
html-safe-nonce25b7fb96544703ca5171e1491a6dade76abcca8376e8f8e90e2a73a6b7f366b5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzIwOjE4QzNCMTozM0E2QUM6NDg4MThEOjZCMDQ3ODMwIiwidmlzaXRvcl9pZCI6IjU4NDIxMTQ5NDcwMzQ5MzczOTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacec0bf7d02083a7b02ed3a5caf8e271fb2ace0a038b4a80a6d2b0e0c0944c31f5
hovercard-subject-tagissue:4391207562
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/5373/issue_layout
twitter:imagehttps://opengraph.githubassets.com/88ed0c874aa9b102f8dd9b4edf69c44c73c46cfa9d374401b3edb658f37321a1/getsentry/sentry-java/issues/5373
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/88ed0c874aa9b102f8dd9b4edf69c44c73c46cfa9d374401b3edb658f37321a1/getsentry/sentry-java/issues/5373
og:image:altProblem If a child OpenTelemetry span is finished after its local root span (which Sentry turns into a transaction) and arrives at SentrySpanExporter in a later exporter batch than the root span, t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameadinauer
hostnamegithub.com
expected-hostnamegithub.com
None9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id3368190
octolytics-dimension-repository_nwogetsentry/sentry-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3368190
octolytics-dimension-repository_network_root_nwogetsentry/sentry-java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecf73f57448d52b3a7b619195e182b33d3b3454ca
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-java/issues/5373#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-java%2Fissues%2F5373
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-java%2Fissues%2F5373
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-java
Reloadhttps://github.com/getsentry/sentry-java/issues/5373
Reloadhttps://github.com/getsentry/sentry-java/issues/5373
Reloadhttps://github.com/getsentry/sentry-java/issues/5373
getsentryhttps://github.com/getsentry
sentry-javahttps://github.com/getsentry/sentry-java
Codehttps://github.com/getsentry/sentry-java
Issues266 (266)https://github.com/getsentry/sentry-java/issues
Pull requests57 (57)https://github.com/getsentry/sentry-java/pulls
Discussionshttps://github.com/getsentry/sentry-java/discussions
Actionshttps://github.com/getsentry/sentry-java/actions
Projectshttps://github.com/getsentry/sentry-java/projects
Security and quality2 (2)https://github.com/getsentry/sentry-java/security
Insightshttps://github.com/getsentry/sentry-java/insights
https://github.com/getsentry/sentry-java
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-java/issues/5373
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-java/issues/5373
Handle delayed OpenTelemetry span finish callshttps://github.com/getsentry/sentry-java/issues/5373#top
BugIssue typehttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Bug%22
JavaSDKhttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Java%22
Platform: Javahttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Platform%3A%20Java%22
Spanshttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Spans%22
https://github.com/adinauer
adinauerhttps://github.com/adinauer
on May 6, 2026https://github.com/getsentry/sentry-java/issues/5373#issue-4391207562
https://github.com/apps/linear-code
linear-codehttps://github.com/apps/linear-code
on May 6, 2026https://github.com/getsentry/sentry-java/issues/5373#issuecomment-4387774249
Linear Codehttps://linear.app
JAVA-500https://linear.app/getsentry/issue/JAVA-500/handle-delayed-opentelemetry-span-finish-calls
github-actionshttps://github.com/apps/github-actions
Platform: Javahttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Platform%3A%20Java%22
on May 6, 2026https://github.com/getsentry/sentry-java/issues/5373#event-25217287606
linear-codehttps://github.com/apps/linear-code
BugIssue typehttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Bug%22
JavaSDKhttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Java%22
Spanshttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Spans%22
on May 6, 2026https://github.com/getsentry/sentry-java/issues/5373#event-25217313516
adinauerhttps://github.com/adinauer
on May 6, 2026https://github.com/getsentry/sentry-java/issues/5373#event-25217895021
test(otel): Relax Kafka coexistence span assertionhttps://github.com/getsentry/sentry-java/commit/3dba80f11d6d6a54200ef10761a2d4924a323afa
3dba80fhttps://github.com/getsentry/sentry-java/commit/3dba80f11d6d6a54200ef10761a2d4924a323afa
feat(core): Queue Instrumentation for Kafka (#5249)https://github.com/getsentry/sentry-java/commit/11ad3372fed13e4508810060fd3997fb786ac176
#5249https://github.com/getsentry/sentry-java/pull/5249
11ad337https://github.com/getsentry/sentry-java/commit/11ad3372fed13e4508810060fd3997fb786ac176
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-java/issues/5373
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-java/issues/5373
BugIssue typehttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Bug%22
JavaSDKhttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Java%22
Platform: Javahttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Platform%3A%20Java%22
Spanshttps://github.com/getsentry/sentry-java/issues?q=state%3Aopen%20label%3A%22Spans%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.