Skip to content

fix(dogstatsd): change stream handler task name to avoid unbounded cardinality#1899

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
tobz/remove-task-id-dsd-stream-handler
Jun 22, 2026
Merged

fix(dogstatsd): change stream handler task name to avoid unbounded cardinality#1899
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
tobz/remove-task-id-dsd-stream-handler

Conversation

@tobz

@tobz tobz commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

As stated in the PR title.

For DSD stream handlers tasks, we were naming them like so: dogstatsd-stream-handler-{}-{}, where the first portion was the listener type (udp, unix, etc) and the second was a "stream index.". For UDP and UDS datagram, this basically meant a single value: zero. For UDS streams, however, this value would grow over time as new connections were established.

On systems with a high volume of connect churn, this can lead to a number of orphaned metrics where the task name is used as a tag, thus creating a unique metric... which in turn becomes a memory leak, and CPU hog as more and more metrics have to be processed, copied during map resizes, and so on.

While we'd like to solve the problem of orphaned metrics not being automatically cleaned up, we're making a tactical fix here since the unbounded cardinality being removed will solve our immediate problem of said memory leakage.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

How did you test this PR?

  • Manual local testing.

References

DADP-2

@tobz tobz requested a review from a team as a code owner June 22, 2026 17:37
@tobz tobz added the type/bug Bug fixes. label Jun 22, 2026
@dd-octo-sts dd-octo-sts Bot added area/components Sources, transforms, and destinations. source/dogstatsd DogStatsD source. labels Jun 22, 2026
@pr-commenter

pr-commenter Bot commented Jun 22, 2026

Copy link
Copy Markdown

Binary Size Analysis (Agent Data Plane)

Baseline: ed28518 · Comparison: 17d7737 · diff
Analysis Configuration: stripped binaries · Pass/Fail Threshold: +5%
Sizes: 40.00 MiB (baseline) vs 39.99 MiB (comparison)
Size Change: -8.65 KiB (-0.02%)

✅ Binary size difference within threshold

Changes by Module
Module File Size Symbols
datadog_protos::trace_piecemeal_include::datadog -15.69 KiB 15
piecemeal +14.86 KiB 16
saluki_components::sources::dogstatsd -5.18 KiB 9
saluki_io::deser::framing +4.98 KiB 1
anon.941f644c74af45a7b365b0b78952794f.208.llvm.15558925246832253497 +3.65 KiB 1
anon.d61d5a4762d8c5c6c36ed71d9c36afeb.106.llvm.2758294315076104356 -3.65 KiB 1
tonic_prost +2.51 KiB 6
tonic -2.20 KiB 12
anon.7daafba63a900654bbfacd253692a086.207.llvm.16753606868781701738 -2.20 KiB 1
anon.ebb7a16da84e2cc5e233b01b11a3a88f.6.llvm.8923889183898943507 +2.20 KiB 1
saluki_components::encoders::datadog -2.08 KiB 20
async_compression -1.92 KiB 6
anon.08437845243d1131cc558e2a7bb9d5ec.84.llvm.14168128347224359581 -1.85 KiB 1
anon.f0802cc9e19d1422c46378c3adadce00.8.llvm.7384586747826047731 +1.85 KiB 1
saluki_components::common::datadog -1.82 KiB 20
anon.84dda3db83196d9922c7aa739c4595af.623.llvm.1419902242594745075 +1.77 KiB 1
anon.1a8e7be65d7457836c3ed6f3f9f85881.614.llvm.7134329971125491430 -1.77 KiB 1
[Unmapped] -1.69 KiB 1
anon.49c036daf795e72869b13248ffc2ab50.98.llvm.3359613750250240013 +1.60 KiB 1
anon.da96181b6473d9c22a8d21ec5a4f1935.1272.llvm.3482570122578118654 -1.60 KiB 1
Detailed Symbol Changes
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [NEW] +5.27Ki  [NEW]     +33    core::ptr::drop_in_place<http_body_util::combinators::map_err::MapErr<http_body_util::combinators::map_err::MapErr<http_body_util::combinators::map_frame::MapFrame<tonic::service::interceptor::ResponseBody<tonic::body::Body>,tonic::codec::decode::Streaming<datadog_protos::agent_include::datadog::model::v1::HostnameReply>::new<tonic::service::interceptor::ResponseBody<tonic::body::Body>,tonic_prost::codec::ProstDecoder<datadog_protos::agent_include::datadog::model::v1::HostnameReply>>::{{closure}}>,tonic::codec::decode::Streaming<datadog_protos::agent_include::datadog::model::v1::HostnameReply>::new<tonic::service::interceptor::ResponseBody<tonic::body::Body>,tonic_prost::codec::ProstDecoder<datadog_protos::agent_include::datadog::model::v1::HostnameReply>>::{{closure}}>,tonic::status::Status::map_error<tonic::status::Status>>>::hd69af6e5120caecd
  [NEW] +4.98Ki  [NEW] +4.81Ki    _<saluki_io::deser::framing::NestedFramer<Inner,Outer> as saluki_io::deser::framing::Framer>::next_frame::hbb2dcdd90174a4c3
  [NEW] +4.47Ki  [NEW] +4.34Ki    alloc::collections::btree::map::entry::VacantEntry<K,V,A>::insert_entry::ha9a62178ecbfb904
  [NEW] +4.03Ki  [NEW] +3.90Ki    alloc::collections::btree::map::entry::VacantEntry<K,V,A>::insert_entry::h86ea9ffc0df5d2c1
  [NEW] +3.65Ki  [NEW]     +16    anon.941f644c74af45a7b365b0b78952794f.208.llvm.15558925246832253497
  +758% +3.31Ki +10e2% +3.31Ki    alloc::collections::btree::map::entry::Entry<K,V,A>::or_default::hc0c18d785ce76d47
  [NEW] +2.49Ki  [NEW]    +422    core::ptr::drop_in_place<tokio::sync::mpsc::bounded::Permit<saluki_components::sources::otlp::OtlpResource>>::h44c27724791a2ffd
  [NEW] +2.49Ki  [NEW]     +47    _<http_body_util::combinators::map_err::MapErr<B,F> as http_body::Body>::size_hint::h90fb3e76900efc4d
  [NEW] +2.39Ki  [NEW]     +61    core::ptr::drop_in_place<std::sync::poison::PoisonError<std::sync::poison::rwlock::RwLockReadGuard<quick_cache::shard::CacheShard<alloc::string::String,saluki_components::sources::otlp::metrics::cache::Extrema,saluki_common::cache::weight::WrappedWeighter<saluki_common::cache::weight::ItemCountWeighter>,foldhash::quality::RandomState,saluki_common::cache::expiry::ExpiryCapableLifecycle<alloc::string::String>,alloc::sync::Arc<quick_cache::sync_placeholder::Placeholder<saluki_components::sources::otlp::metrics::cache::Extrema>>>>>>::h90b144a9ae831da6
  [DEL] -2.20Ki  [DEL]     -85    anon.7daafba63a900654bbfacd253692a086.207.llvm.16753606868781701738
  [DEL] -2.39Ki  [DEL]     -61    core::ptr::drop_in_place<std::sync::poison::PoisonError<std::sync::poison::rwlock::RwLockReadGuard<quick_cache::shard::CacheShard<stringtheory::MetaString,core::option::Option<saluki_components::transforms::dogstatsd_mapper::CachedMapResult>,saluki_common::cache::weight::WrappedWeighter<saluki_common::cache::weight::ItemCountWeighter>,foldhash::quality::RandomState,saluki_common::cache::expiry::ExpiryCapableLifecycle<stringtheory::MetaString>,alloc::sync::Arc<quick_cache::sync_placeholder::Placeholder<core::option::Option<saluki_components::transforms::dogstatsd_mapper::CachedMapResult>>>>>>>::h7d332629602cbf35
  [DEL] -2.49Ki  [DEL]     -47    _<http_body_util::combinators::map_err::MapErr<B,F> as http_body::Body>::size_hint::he3c4865aba9d0e04
  [DEL] -2.50Ki  [DEL]    -422    core::ptr::drop_in_place<tokio::sync::mpsc::bounded::Permit<saluki_core::data_model::event::Event>>::h95c96848129ea310
  [DEL] -3.40Ki  [DEL] -3.09Ki    alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::Leaf>,alloc::collections::btree::node::marker::Edge>::insert_recursing::h4c4c158861486472
  [DEL] -3.65Ki  [DEL]     -16    anon.d61d5a4762d8c5c6c36ed71d9c36afeb.106.llvm.2758294315076104356
  [DEL] -4.32Ki  [DEL] -4.02Ki    alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::Leaf>,alloc::collections::btree::node::marker::Edge>::insert_recursing::hf3efc4b12bcf582f
  [DEL] -4.33Ki  [DEL] -4.03Ki    alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut,K,V,alloc::collections::btree::node::marker::Leaf>,alloc::collections::btree::node::marker::Edge>::insert_recursing::hacb1688944c2ef39
  [DEL] -4.98Ki  [DEL] -4.81Ki    _<saluki_components::sources::dogstatsd::framer::DsdFramer as saluki_io::deser::framing::Framer>::next_frame::hcb8e09be2f29ab6e
  -0.0%    -425  -0.2% -5.01Ki    [5144 Others]
  [DEL] -5.27Ki  [DEL]     -33    core::ptr::drop_in_place<http_body_util::combinators::map_err::MapErr<http_body_util::combinators::map_err::MapErr<http_body_util::combinators::map_frame::MapFrame<tonic::service::interceptor::ResponseBody<tonic::body::Body>,tonic::codec::decode::Streaming<datadog_protos::agent_include::datadog::remoteagent::v1::RefreshRemoteAgentResponse>::new<tonic::service::interceptor::ResponseBody<tonic::body::Body>,tonic_prost::codec::ProstDecoder<datadog_protos::agent_include::datadog::remoteagent::v1::RefreshRemoteAgentResponse>>::{{closure}}>,tonic::codec::decode::Streaming<datadog_protos::agent_include::datadog::remoteagent::v1::RefreshRemoteAgentResponse>::new<tonic::service::interceptor::ResponseBody<tonic::body::Body>,tonic_prost::codec::ProstDecoder<datadog_protos::agent_include::datadog::remoteagent::v1::RefreshRemoteAgentResponse>>::{{closure}}>,tonic::status::Status::map_error<tonic::status::S
  [DEL] -5.79Ki  [DEL] -5.64Ki    datadog_protos::trace_piecemeal_include::datadog::trace::AgentPayloadBuilder<S>::add_tracer_payloads::h3830f18d18f5b1f1
  -0.0% -8.65Ki  -0.0% -10.3Ki    TOTAL

@pr-commenter

pr-commenter Bot commented Jun 22, 2026

Copy link
Copy Markdown

Regression Detector (Agent Data Plane)

Run ID: 02e0872f-5407-4e79-9f1f-8ae70cb7b52c
Baseline: ed285181 · Comparison: 17d77375 · diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment (35)

Experiments configured erratic: true are tagged (ignored) and skipped when determining which experiments regressed or improved. Experiments which are detected as erratic at runtime are tagged (erratic) to flag that the run's sample dispersion was high, but their regression / improvement signal still counts.

experiment goal Δ mean % links
otlp_ingest_logs_5mb_memory (ignored) memory ⚪ +2.97 metrics profiles logs
dsd_uds_512kb_3k_contexts_cpu (erratic) cpu ⚪ +1.77 metrics profiles logs
otlp_ingest_traces_ottl_filtering_5mb_cpu (erratic) cpu ⚪ +1.44 metrics profiles logs
otlp_ingest_metrics_5mb_memory memory ⚪ +1.19 metrics profiles logs
otlp_ingest_logs_5mb_cpu (ignored) cpu ⚪ +1.15 metrics profiles logs
otlp_ingest_traces_ottl_transform_5mb_cpu (erratic) cpu ⚪ +1.14 metrics profiles logs
dsd_uds_500mb_3k_contexts_throughput throughput ⚪ -0.46 metrics profiles logs
quality_gates_rss_idle memory ⚪ +0.35 metrics profiles logs
quality_gates_rss_dsd_low memory ⚪ +0.31 metrics profiles logs
otlp_ingest_traces_ottl_transform_5mb_throughput throughput ⚪ -0.28 metrics profiles logs
quality_gates_rss_dsd_ultraheavy memory ⚪ +0.21 metrics profiles logs
dsd_uds_500mb_3k_contexts_memory memory ⚪ +0.18 metrics profiles logs
otlp_ingest_traces_ottl_transform_5mb_memory memory ⚪ +0.18 metrics profiles logs
otlp_ingest_traces_5mb_memory memory ⚪ +0.10 metrics profiles logs
otlp_ingest_traces_ottl_filtering_5mb_memory memory ⚪ +0.09 metrics profiles logs
otlp_ingest_traces_5mb_throughput throughput ⚪ -0.07 metrics profiles logs
dsd_uds_10mb_3k_contexts_memory memory ⚪ +0.07 metrics profiles logs
otlp_ingest_traces_ottl_filtering_5mb_throughput throughput ⚪ -0.04 metrics profiles logs
dsd_uds_100mb_3k_contexts_throughput throughput ⚪ -0.00 metrics profiles logs
dsd_uds_1mb_3k_contexts_throughput throughput ⚪ -0.00 metrics profiles logs
dsd_uds_512kb_3k_contexts_throughput throughput ⚪ -0.00 metrics profiles logs
dsd_uds_10mb_3k_contexts_throughput throughput ⚪ +0.01 metrics profiles logs
dsd_uds_1mb_3k_contexts_memory memory ⚪ -0.01 metrics profiles logs
otlp_ingest_logs_5mb_throughput (ignored) throughput ⚪ +0.03 metrics profiles logs
otlp_ingest_metrics_5mb_throughput throughput ⚪ +0.05 metrics profiles logs
quality_gates_rss_dsd_medium memory ⚪ -0.07 metrics profiles logs
dsd_uds_100mb_3k_contexts_cpu (erratic) cpu ⚪ -0.08 metrics profiles logs
dsd_uds_500mb_3k_contexts_cpu (erratic) cpu ⚪ -0.09 metrics profiles logs
dsd_uds_512kb_3k_contexts_memory memory ⚪ -0.21 metrics profiles logs
dsd_uds_100mb_3k_contexts_memory memory ⚪ -0.22 metrics profiles logs
quality_gates_rss_dsd_heavy memory ⚪ -0.26 metrics profiles logs
otlp_ingest_traces_5mb_cpu (erratic) cpu ⚪ -0.64 metrics profiles logs
otlp_ingest_metrics_5mb_cpu (erratic) cpu ⚪ -0.77 metrics profiles logs
dsd_uds_1mb_3k_contexts_cpu (erratic) cpu ⚪ -1.66 metrics profiles logs
dsd_uds_10mb_3k_contexts_cpu (erratic) cpu 🟢 -7.03 metrics profiles logs
Bounds Checks: ✅ Passed (5)
experiment check replicates observed links
quality_gates_rss_dsd_heavy memory_usage 10/10 ✅ 131 MiB ≤ 140 MiB metrics profiles logs
quality_gates_rss_dsd_low memory_usage 10/10 ✅ 42.2 MiB ≤ 50 MiB metrics profiles logs
quality_gates_rss_dsd_medium memory_usage 10/10 ✅ 65.2 MiB ≤ 75 MiB metrics profiles logs
quality_gates_rss_dsd_ultraheavy memory_usage 10/10 ✅ 191 MiB ≤ 200 MiB metrics profiles logs
quality_gates_rss_idle memory_usage 10/10 ✅ 28 MiB ≤ 40 MiB metrics profiles logs
Explanation

A change is flagged as a regression when |Δ mean %| > 5.00% in the regressing direction for its optimization goal AND SMP marks the experiment as a regression (is_regression: true). Improvements use the matching criteria for the improving direction. Experiments configured erratic: true (tagged (ignored)) are skipped outright; experiments detected as erratic at runtime (tagged (erratic)) still count, since that flag describes sample dispersion rather than directional certainty. The Δ mean % cell is colored accordingly: 🟢 = improvement, 🔴 = regression, ⚪ = neutral. Reduction in CPU or memory is an improvement; reduction in ingress throughput is a regression.

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit aeda7d8 into main Jun 22, 2026
87 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the tobz/remove-task-id-dsd-stream-handler branch June 22, 2026 18:06
dd-octo-sts Bot pushed a commit that referenced this pull request Jun 22, 2026
…rdinality (#1899)

## Summary

As stated in the PR title.

For DSD stream handlers tasks, we were naming them like so: `dogstatsd-stream-handler-{}-{}`, where the first portion was the listener type (`udp`, `unix`, etc) and the second was a "stream index.". For UDP and UDS datagram, this basically meant a single value: zero. For UDS streams, however, this value would grow over time as new connections were established.

On systems with a high volume of connect churn, this can lead to a number of orphaned metrics where the task name is used as a tag, thus creating a unique metric... which in turn becomes a memory leak, and CPU hog as more and more metrics have to be processed, copied during map resizes, and so on.

While we'd like to solve the problem of orphaned metrics not being automatically cleaned up, we're making a tactical fix here since the unbounded cardinality being removed will solve our immediate problem of said memory leakage.

## Change Type
- [x] Bug fix
- [ ] New feature
- [ ] Non-functional (chore, refactoring, docs)
- [ ] Performance

## How did you test this PR?

- Manual local testing.

## References

DADP-2

Co-authored-by: toby.lawrence <toby.lawrence@datadoghq.com> aeda7d8
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Jun 22, 2026
…rdinality (backport #1899 to 1.2.x) (#1902)

## Summary

Backport of #1899 to the `releases/1.2.x` line.

## Backport notes

Our cherry pick of `aeda7d87a1bd7acc0f00e35d993862dc45c1a32d` didn't apply cleanly itself but the diff we have here is identical to the diff in the original PR.

## Change Type
- [x] Bug fix
- [ ] New feature
- [ ] Non-functional (chore, refactoring, docs)
- [ ] Performance

## How did you test this PR?

- Manual local testing (original PR).
- `cargo check -p saluki-components` on the backport branch.

## References

DADP-2

Co-authored-by: toby.lawrence <toby.lawrence@datadoghq.com>
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Jun 22, 2026
## Summary

Bumps the `agent-data-plane` crate version from `1.2.1` to `1.2.2`.

This release contains the backport of #1899 (DSD stream-handler task-name cardinality fix), landed via #1902.

## Change Type
- [ ] Bug fix
- [ ] New feature
- [x] Non-functional (chore, refactoring, docs)
- [ ] Performance

## How did you test this PR?

N/A

## References

DADP-2

Co-authored-by: toby.lawrence <toby.lawrence@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/components Sources, transforms, and destinations. mergequeue-status: done source/dogstatsd DogStatsD source. type/bug Bug fixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants