Skip to content

feat(core): implement Tracing without Performance #811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

lcian
Copy link
Member

@lcian lcian commented May 19, 2025

Implements Tracing without Performance (spec).

This is done by having an additional PropagationContext attribute on the scope that holds a "fake" trace_id and span_id.
When applying the scope to an event, if there is no ongoing span set on the scope, we create the trace context from the PropagationContext.
Additionally, adds an API scope.iter_trace_propagation_headers that should be preferred over something like:

sentry::configure_scope(|scope| {
	if let Some(span) = scope.get_span() {
		headers = Some(span.iter_headers());
	} 
});

because it will use the PropagationContext as a fallback.

Closes #796

Also makes a minor adjustment to trace and span ids where we now use the Display impl for Debug, otherwise we were getting u8 arrays when using e.g. dbg! with the derived one which is not very useful.

Copy link

codecov bot commented May 19, 2025

Codecov Report

Attention: Patch coverage is 58.62069% with 24 lines in your changes missing coverage. Please review.

Project coverage is 72.99%. Comparing base (bec93d2) to head (8cf93b8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #811      +/-   ##
==========================================
- Coverage   73.23%   72.99%   -0.25%     
==========================================
  Files          62       62              
  Lines        7238     7279      +41     
==========================================
+ Hits         5301     5313      +12     
- Misses       1937     1966      +29     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lcian lcian requested a review from szokeasaurusrex May 19, 2025 14:54
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Looks good overall, I have some (mostly minor) suggestions though

Comment on lines +777 to +778
/// Use [`crate::Scope::iter_trace_propagation_headers`] to obtain the active
/// span's/transaction's distributed tracing headers.
Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is that this could also return the ids from PropagationContext if there is no ongoing span, not sure if this comment correctly reflects that.
But on the other hand we should also hide PropagationContext as that's an "implementation detail".

@@ -1133,6 +1140,15 @@ pub struct TraceHeadersIter {
sentry_trace: Option<String>,
}

impl TraceHeadersIter {
#[cfg_attr(not(feature = "client"), allow(dead_code))]
Copy link
Member Author

Choose a reason for hiding this comment

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

If client is not active then we will use the noop scope that doesn't call this

@lcian lcian requested a review from szokeasaurusrex May 22, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracing without Performance
2 participants