-
Notifications
You must be signed in to change notification settings - Fork 104
feat(spans): Allow ingestion of metrics summary on spans #2823
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
Conversation
| // Check feature flag. | ||
| if !state | ||
| .project_state | ||
| .has_feature(Feature::SpanMetricsExtraction) | ||
| { | ||
| // When span metrics extraction is disabled, we need to check if DDM is enabled | ||
| // to still index spans with _metrics_summary | ||
| if !state.project_state.has_feature(Feature::CustomMetrics) { | ||
| return; | ||
| } | ||
|
|
||
| let Some(event) = state.event.value() else { | ||
| return; | ||
| }; | ||
|
|
||
| // Metrics summary is empty so we don't need to ingest the span. | ||
| if event._metrics_summary.is_empty() { | ||
| return; | ||
| } | ||
|
|
||
| // Extract transaction as a span. | ||
| let mut transaction_span: Span = event.into(); | ||
|
|
||
| // Extract tags to add to this span as well | ||
| let shared_tags = tag_extraction::extract_shared_tags(event); | ||
| transaction_span.sentry_tags = Annotated::new( | ||
| shared_tags | ||
| .clone() | ||
| .into_iter() | ||
| .map(|(k, v)| (k.sentry_tag_key().to_owned(), Annotated::new(v))) | ||
| .collect(), | ||
| ); | ||
| add_span(transaction_span.into()); | ||
|
|
||
| return; | ||
| }; |
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.
Do we really need this extra logic? Span metrics extraction is at 100% anyway, right? Or are we trying to run this experiment on other instances (S4S)?
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.
We're trying to run this on S4S, where span metrics extraction is not enabled.
| // Extract transaction as a span. | ||
| let mut transaction_span: Span = event.into(); | ||
|
|
||
| // Extract tags to add to this span as well | ||
| let shared_tags = tag_extraction::extract_shared_tags(event); | ||
| transaction_span.sentry_tags = Annotated::new( | ||
| shared_tags | ||
| .clone() | ||
| .into_iter() | ||
| .map(|(k, v)| (k.sentry_tag_key().to_owned(), Annotated::new(v))) | ||
| .collect(), | ||
| ); | ||
| add_span(transaction_span.into()); |
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.
Even if we need this extra logic (see comment below), I think we could prevent copying this snippet and instead have something like
let extract_transaction_span = extraction_enabled || (custom_metrics_enabled && !summary.is_empty());
let extract_child_spans = extraction_enabled;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.
True. I refactored it.
jjbayer
left a comment
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.
Let's also add a test to verify that spans are extracted when custom metrics are enabled (can be either a unit test of extract_from_event or a copy-paste of test_span_extraction).
* master: (35 commits) fix(spans): Parse quotes in MySQL (#2846) ref(cardinality): Use a Lua script and in-memory cache for the cardinality limiter (#2849) fix(spans): Detect hex with fallback scrubber (#2868) release: 23.12.0 Revert "ci: Update upload-artifact and download-artifact actions" (#2866) Revert "build: Update axum and http" (#2863) feat(spans): Allow resource.img spans (#2855) build: Update axum and http (#2844) fix(build): Add additional dependencies to the release build (#2858) ci: Update upload-artifact and download-artifact actions (#2861) feat(spans): Parse timestamps from strings (#2857) fix(spans): Scrub integer file extensions (#2856) feat(spans): Remove unused transaction tag from resource metrics (#2853) ref(cardinality): Recover buckets on cardinality limiter failure (#2852) feat(server): Org rate limit per metric bucket (#2836) ref(spans): List metric tags explicitly (#2834) feat(spans): Resource response sizes as measurements (#2845) feat(crons): Add thresholds to monitor config payload (#2842) feat(spans): Allow ingestion of metrics summary on spans (#2823) ref(crons): Add documentation to CheckInMessageType (#2840) ...
In order to ingest metrics summary on spans, we need to add the field to the protocol and copy it during extraction.
On top of that, since span extraction is not always enabled when DDM is, we check if we need to persist the span by looking if it contains a non-empty metrics summary value and then persist the span if it does.