Skip to content

feat(develop): Add new_trace()#16093

Merged
sentrivana merged 5 commits into
masterfrom
ivana/span-first/new-trace
Jan 22, 2026
Merged

feat(develop): Add new_trace()#16093
sentrivana merged 5 commits into
masterfrom
ivana/span-first/new-trace

Conversation

@sentrivana

@sentrivana sentrivana commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Add API to clear the propagation context. Add some examples, too.

Preview: https://develop-docs-git-ivana-span-firstnew-trace.sentry.dev/sdk/telemetry/spans/span-trace-propagation/

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

@vercel

vercel Bot commented Jan 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
develop-docs Ready Ready Preview, Comment Jan 22, 2026 7:42am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
sentry-docs Ignored Ignored Preview Jan 22, 2026 7:42am

Request Review

Comment on lines +23 to +29

```python
import sentry_sdk

sentry_sdk.continue_trace(request.headers)
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should align this across SDKs. The snippets here currently do not related to any implementation but we should pick one and document it via pseudo code.

@sentrivana sentrivana Jan 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lms24 Is the JS example up to date? I have two reservations regarding it:

  • It's not top-level API, but scope API, which means users would need to be aware of the scope system and pick the correct scope to put the propagation context on. Given that even we ourselves struggle with this 🤣 I don't think that's a good idea.
  • It's not immediately clear what it (a propagation context) does. Compare this with e.g. continueTrace which is intuitive.

Could we align on continue_trace()/continueTrace() or something similar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related, I didn't touch these in this PR but I have similar concerns about

traceparent = scope.getTraceparent()
baggage = scope.getBaggage()

Those should ideally also not have anything to do with a specific scope, but rather be top level, and we pick the correct scope to retrieve them from in the background.

traceparent = sentry_sdk.get_traceparent()
baggage = sentry_sdk.get_baggage()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with changing this to use global functions.

@Lms24 Lms24 Jan 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, these snippets (at the time of writing) were meant to be low-level pseudocode (shouldn't have used the javascript langauge for this). In JS, today, we have Sentry.continueTrace:

Sentry.continueTrace({
  sentryTrace: request.headers['sentry-trace'],
  baggage: request.headers['baggage'],
}, () => {
  Sentry.startSpan({ name: 'test' }, () => {
    // ....
  });
})

Which, besides the callback, is very similar to what is being proposed here IIUC.

@Lms24 Lms24 Jan 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing:

traceparent = sentry_sdk.get_traceparent()
baggage = sentry_sdk.get_baggage()

Sounds fine to me! We went down a slightly different route in JS and exported a Sentry.getTraceData() API which returns a dict/object with both headers (actually, 3, if propagateTraceParent is enabled). Our thinking back then was, there's no reason to only need one of these headers, so let's take care of them together. Not saying we should generalize this because the two separate ones can be combined and built upon. Just pointing out prior art 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lms24 Since I'm already updating all the examples, there's

traceparent = scope.getTraceparent()
baggage = scope.getBaggage()

How does this actually look in JS? I found getTraceData(), is that it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, commented about the same thing at the same time 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thank you both, updated if anyone wants to give this a last pass.

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this! I think both, new_trace and continue_trace make sense and are similar to what we already have in JS!

Comment thread develop-docs/sdk/telemetry/spans/span-trace-propagation.mdx
Comment thread develop-docs/sdk/telemetry/spans/span-trace-propagation.mdx
Comment thread develop-docs/sdk/telemetry/spans/span-trace-propagation.mdx Outdated
Comment thread develop-docs/sdk/telemetry/spans/span-trace-propagation.mdx Outdated
Comment thread develop-docs/sdk/telemetry/spans/span-trace-propagation.mdx
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
@sentrivana sentrivana enabled auto-merge (squash) January 22, 2026 07:38
@sentrivana sentrivana merged commit 2102e8d into master Jan 22, 2026
14 checks passed
@sentrivana sentrivana deleted the ivana/span-first/new-trace branch January 22, 2026 07:42
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants