Skip to content

Conversation

@phacops
Copy link
Contributor

@phacops phacops commented Dec 6, 2023

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.

@phacops phacops requested review from jjbayer and mitsuhiko December 6, 2023 23:01
@phacops phacops self-assigned this Dec 6, 2023
@phacops phacops requested a review from a team as a code owner December 6, 2023 23:01
Comment on lines 145 to 180
// 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;
};
Copy link
Member

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)?

Copy link
Contributor Author

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.

Comment on lines 165 to 177
// 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());
Copy link
Member

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;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I refactored it.

@phacops phacops requested a review from jjbayer December 8, 2023 14:56
Copy link
Member

@jjbayer jjbayer left a 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).

@phacops phacops requested a review from jjbayer December 11, 2023 14:22
@phacops phacops merged commit 5d6b523 into master Dec 12, 2023
@phacops phacops deleted the pierre/spans-add-metrics-summary branch December 12, 2023 18:48
jan-auer added a commit that referenced this pull request Dec 19, 2023
* 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)
  ...
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.

5 participants