-
-
Notifications
You must be signed in to change notification settings - Fork 180
feat(metrics): Associate trace data with metrics #1061
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
base: szokeasaurusrex/core-metrics-capture
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ use std::sync::Mutex; | |
| use std::sync::{Arc, PoisonError, RwLock}; | ||
|
|
||
| use crate::performance::TransactionOrSpan; | ||
| #[cfg(feature = "metrics")] | ||
| use crate::protocol::Metric; | ||
| use crate::protocol::{ | ||
| Attachment, Breadcrumb, Context, Event, Level, TraceContext, Transaction, User, Value, | ||
| }; | ||
|
|
@@ -399,6 +401,17 @@ impl Scope { | |
| } | ||
| } | ||
|
|
||
| /// Applies the contained scoped data to a trace metric, setting the `trace_id` and `span_id`. | ||
| #[cfg(feature = "metrics")] | ||
| pub(crate) fn apply_to_metric(&self, metric: &mut Metric) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent visibility between noop and real
|
||
| metric.trace_id = self | ||
| .get_span() | ||
| .map(|span| span.get_trace_context().trace_id) | ||
| .unwrap_or(self.propagation_context.trace_id); | ||
|
|
||
| metric.span_id = self.get_span().map(|span| span.span_id()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should fall back on the propagation context to get the span ID, as it seems the Python implementation does it that way: https://github.com/getsentry/sentry-python/blob/5d26c2f60e289c89ab260ee25607a3bea5e174c9/sentry_sdk/scope.py#L1828. I saw that logs do the same and only consider |
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant double
|
||
|
|
||
| /// Set the given [`TransactionOrSpan`] as the active span for this scope. | ||
| pub fn set_span(&mut self, span: Option<TransactionOrSpan>) { | ||
| self.span = Arc::new(span); | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also return just
Metric. If we need to havebefore_send_metric(not sure if that exists) then I guessOption<Metric>makes sense though. It's an internal API anyway so it doesn't really matter.