Add StatsDCounterKey/StatsDCountReporter glue for Accumulator - #12360
Draft
dougqh wants to merge 2 commits into
Draft
Add StatsDCounterKey/StatsDCountReporter glue for Accumulator#12360dougqh wants to merge 2 commits into
dougqh wants to merge 2 commits into
Conversation
Lets an enum used as an Accumulator key declare its own dogstatsd metric name, and drains an Accumulator.accumulateAndReset() result to StatsDClient in one call. No caller wired in yet -- TracerHealthMetrics migration is a follow-up PR. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds JUnit5 test dependency to metrics-api (previously had none), a RecordingStatsDClient test fake, and coverage for non-zero/zero/ negative deltas and tag pass-through. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
🎯 Code Coverage (details) 🔗 Commit SHA: 264a2ef | Docs | View more details | Give us feedback! |
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Adds
StatsDCounterKeyandStatsDCountReporterinproducts/metrics/metrics-api: reusable glue that lets anenumused as anAccumulatorkey declare its own dogstatsd metric name at the declaration site, and drains anAccumulator.accumulateAndReset(...)result to aStatsDClientin one call, skipping zero-delta counters.This is groundwork only -- no caller is wired in yet. The natural first caller is
TracerHealthMetrics(currently ~49 individualLongAdderfields, each diffed by hand against a fixed-sizepreviousCountsarray), but that migration is scoped to a separate follow-up PR.Motivation
Accumulator(#12351) has no consumer yet. Before wiring one in, this PR builds the small reusable piece that makes adoption mechanical: one interface for an enum to name its own metric, one static helper to report a drained counter array. Keeping this separate from theTracerHealthMetricsmigration keeps that follow-up PR focused on the migration itself rather than also inventing this glue inline.This is explicitly a consolidation move: the codebase already has several ad hoc ways to get a counter's value to a metrics sink (
CoreCounter/StatsMetrics.TaggedCounter, theMetricCollectorSPI,CiVisibilityCountMetric's tag-combination encoding). None of them fitAccumulator's enum-ordinal, tag-less shape, so this adds the smallest new piece rather than reusing a mismatched one -- see the design note inStatsDCounterKey's Javadoc for the intended usage shape.Additional Notes
products/metrics/metrics-apihad no test dependencies before this PR; addedtestImplementation(libs.bundles.junit5)(matches the pattern in sibling modulesmetrics-lib,feature-flagging-api)../gradlew :products:metrics:metrics-api:test --tests "datadog.metrics.api.statsd.StatsDCountReporterTest"-- all pass./gradlew :products:metrics:metrics-api:spotlessCheck-- clean/techdebtand/perf-reviewrun over branch changes -- no findings on either passContributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueJira ticket: APMLP-1779