Feature Request: Trace Correlations — Configure external observability links at the SDK/project layer (not hardcoded in app code)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 44.8k
- Forks
- 4.9k
- Avg merge
- 21h 23m
- Merged PRs (30d)
- 607
Description
Problem / Motivation
Grafana has a feature called Trace Correlations that lets you define URL template rules at the data source config level. When viewing a trace, Grafana injects clickable links into span detail views based on span attribute values — without any app code changes.
Sentry currently has no equivalent. The only way to attach an external link (e.g. a Grafana/Tempo trace URL or a Splunk log URL) to a Sentry span is to hardcode it in SDK instrumentation code:
// Android — must be done in app code today
Sentry.getSpan()?.apply {
setData("tempo.trace_id", tempoTraceId)
setData("tempo.url", "https://grafana.example.com/explore?...")
}
# Python backend — same problem
with sentry_sdk.start_span(op="http.server") as span:
span.set_data("tempo.trace_id", tempo_trace_id)
span.set_data("tempo.url", f"https://grafana.example.com/explore?...")
This approach has real production problems:
- URL fragility — If the Grafana domain, org ID, or datasource name changes, every SDK call in every app must be updated and re-released. There is no central config to update.
- No retroactive correction — Spans already recorded with a stale URL cannot be updated after the fact.
- Multi-platform coordination — Android, iOS, and Python backend teams all have to independently implement and maintain the same URL-building logic.
- Extends beyond Tempo — The same need exists for Splunk logs, Datadog, New Relic, or any other observability backend. Each requires its own hardcoded URL template.
- Renders as plain text, not a link — Sentry does not currently render span data values as clickable links in the trace detail view, so the UX benefit is limited even after all that instrumentation work.
Architecture Context
This came from a real customer running Sentry on Android/iOS apps with Grafana/Tempo on their backend (via OTLP). They deliberately do not propagate traceparent from mobile through their API gateway (Kong) because:
- Kong treats inbound observability headers as untrusted external data
- Their backend uses tail-based sampling, which conflicts with app-side sampling decisions
- Tempo would only receive incomplete backend-only traces if it continued the app trace — the root spans would always be missing
They have two separate trace systems and want to correlate them explicitly rather than make them one physical trace. Grafana already solves this on the Grafana→Sentry direction via trace correlations. They need Sentry to solve it in the Sentry→Grafana direction.
The same pattern applies to Splunk, Datadog, or any other backend observability tool used alongside Sentry.
Requested Feature
A Trace Correlations config in Sentry — at the project settings level in sentry.io and optionally at SDK init — that:
- Accepts a list of rules:
{ spanAttribute, urlTemplate, label }pairs - At render time in the Sentry UI, evaluates the template against live span attribute values and injects a clickable link into the span detail view
- Requires no app code changes when URLs, domains, or external systems change — just update the config in sentry.io
Proposed API
Project Settings UI (primary ask)
Under Project Settings → Tracing → Trace Correlations, a config panel where you define:
| Field | Example |
|---|---|
| Span attribute | tempo.trace_id |
| URL template | https://grafana.example.com/explore?orgId=1&...&query={value} |
| Display label | View in Grafana/Tempo |
SDK-level config (optional / power users)
Python:
sentry_sdk.init(
dsn="...",
trace_correlations=[
{
"label": "View in Grafana/Tempo",
"span_attribute": "tempo.trace_id",
"url_template": "https://grafana.example.com/explore?orgId=1&left=...&query={value}"
},
{
"label": "View in Splunk",
"span_attribute": "splunk.trace_id",
"url_template": "https://splunk.example.com/en-US/app/search/search?q=trace_id%3D{value}"
}
]
)
Android/Kotlin:
SentryAndroid.init(context) { options ->
options.traceCorrelations = listOf(
TraceCorrelation(
label = "View in Grafana/Tempo",
spanAttribute = "tempo.trace_id",
urlTemplate = "https://grafana.example.com/explore?orgId=1&...&query={value}"
),
TraceCorrelation(
label = "View in Splunk",
spanAttribute = "splunk.trace_id",
urlTemplate = "https://splunk.example.com/search?q=trace_id%3D{value}"
)
)
}
Desired Rendering in Sentry UI
In the span detail view, for any span with tempo.trace_id set, Sentry renders:
tempo.trace_id 4bf92f3577b34da6a3ce929d0e0e4736 [View in Grafana/Tempo ↗]
The label is a clickable link opening the correlated trace in the external system. No app code changes needed when the URL template changes.
Affected Surface Areas
- Sentry UI — span detail view (trace correlations rendering)
- Sentry UI — Project Settings (trace correlations config panel)
sentry-pythonsentry-java/sentry-androidsentry-cocoa(iOS/macOS)
References
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by mapping the Sentry UI span detail view and Project Settings surfaces described in the issue, then review the sentry-python and sentry-java/sentry-android SDK init entry points. Compare the requested project-level rules with the optional SDK configuration and determine how span attributes and URL templates should be represented. Done means configured correlations render as clickable labeled links without app code changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, python
- Domain
- backend, frontend, mobile-dev, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100