feat(stats)!: add telemetry for per-field cardinality limits#2212
feat(stats)!: add telemetry for per-field cardinality limits#2212Eldolfin wants to merge 16 commits into
Conversation
save memory by storing value hashes only, u64 has enough values to make collisions rare and in case we still get a collision storing 1 extra key should be fine
…alityLimitConfig binding
|
@codex review |
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 3973435 | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
| debug!( | ||
|
|
||
| if total_collapsed.whole_key > 0 { | ||
| once!(debug!( |
There was a problem hiding this comment.
It must be emited once per flush period so no need to add a once macro
| let collapsed_resources = handle.register_metric_context( | ||
| COLLAPSED_SPANS_TELEMETRY_METRIC.to_string(), | ||
| vec![libdd_common::tag!("collapsed_spans", "resource")], | ||
| libdd_telemetry::data::metrics::MetricType::Count, | ||
| true, | ||
| libdd_telemetry::data::metrics::MetricNamespace::Tracers, | ||
| ); | ||
| let collapsed_http_endpoints = handle.register_metric_context( | ||
| COLLAPSED_SPANS_TELEMETRY_METRIC.to_string(), | ||
| vec![libdd_common::tag!("collapsed_spans", "http_endpoint")], | ||
| libdd_telemetry::data::metrics::MetricType::Count, | ||
| true, | ||
| libdd_telemetry::data::metrics::MetricNamespace::Tracers, | ||
| ); | ||
| let collapsed_peer_tags = handle.register_metric_context( | ||
| COLLAPSED_SPANS_TELEMETRY_METRIC.to_string(), | ||
| vec![libdd_common::tag!("collapsed_spans", "peer_tags")], | ||
| libdd_telemetry::data::metrics::MetricType::Count, | ||
| true, | ||
| libdd_telemetry::data::metrics::MetricNamespace::Tracers, | ||
| ); | ||
| let collapsed_additional_tags = handle.register_metric_context( | ||
| COLLAPSED_SPANS_TELEMETRY_METRIC.to_string(), | ||
| vec![libdd_common::tag!( | ||
| "collapsed_spans", | ||
| "additional_metric_tags" | ||
| )], | ||
| libdd_telemetry::data::metrics::MetricType::Count, | ||
| true, | ||
| libdd_telemetry::data::metrics::MetricNamespace::Tracers, | ||
| ); |
There was a problem hiding this comment.
From the RFC
(Multiple
collapsed:tags should be added when more than one field is collapsed)
I think it means we should send a single count metric with all the offending fields in the bucket instead of separate count metrics. I think the reason is because otherwise COLLAPSED_SPANS_TELEMETRY_METRIC will not count the number of collapsed spans but the total number of fields collapsed.
| /// Maximum number of distinct aggregation keys this bucket will hold before collapsing new | ||
| /// ones into the overflow sentinel key. | ||
| cardinality_limits: CardinalityLimitConfig, | ||
| // HashSet of hashes of values so save memory, no need for total accuracy here |
There was a problem hiding this comment.
Maybe detail a bit more why it's not accurate and how much collision we can escape as it can be a bit confusing we reading the code
abb8d3a to
efe280f
Compare
efe280f to
83043a4
Compare
What does this PR do?
Send telemetry about per-field cardinality collapses.
Motivation
CSS spec compliance.
Additional Notes
Not a fan of how much I need to duplicate some parts of the code. But I wanted to avoid using HashMaps everywhere and keep the changes simple.
Maybe some sort of macro magic can solve this ? But I'm afraid it might hurt readability even more. I'm open to suggestions
How to test the change?
Describe here in detail how the change can be validated.