Repository navigation
Record telemetry metrics through handles with typed tags - #403
cataphract wants to merge 3 commits into
Conversation
A metric is registered once with typed tags, so recording a point builds, copies and hashes no tag strings. Nothing uses the handles yet.
Telemetry owns a registry of handles, created with counter::create, rate::create and distribution::create. Distributions go out as sketches.
The tracer and telemetry record their metrics through handles, so the old API, which copied and hashed tag strings on every call, is removed.
BenchmarksBenchmark execution time: 2026-11-13 23:40:16 Comparing candidate commit 7face92 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 7 metrics, 0 unstable metrics.
|
|
Closing to split |
Overview
Replaces the string-tagged metric functions, such as
counter::increment(metric, {"tag:value"}), with metric handles. A handle is created once, with its fixed tags and a struct that describes its other tags. Recording a point then takes that struct and a number. Distributions are now sent as sketches, using theLogBinnedDistrof #401.Stacked on #401.
Motivation
nginx-datadog will record AppSec metrics on every request. The old API built, copied and hashed a vector of tag strings for each point, under one global lock. A handle instead computes a series id from the tag values and updates its own store. Tag strings are built only when telemetry sends the series.
Additional Notes
tag_value_names), abool, anOptionalenum (not sent when empty) or aTagString, for values not known in advance. ATagStringis interned; after 65535 strings, new ones are sent asother. Astatic_assertchecks that every combination of tag values fits in the 64-bit series id.counter::create,rate::createanddistribution::createmake the handles. Telemetry holds only weak references to them: a handle that its owner drops is forgotten, so the metric can be created again with other fixed tags. A handle created beforetelemetry::initrecords values that are never sent.counter::increment,decrementandset,rate::setanddistribution::addare removed.distributionspayload is no longer sent. Distributions go in asketchespayload.TracerMetrics, created on first use. Four metrics that were declared but never recorded are dropped:trace_chunks_enqueued_for_serialization,context_header_truncated,trace_api.msandtelemetry_api.ms.References
Jira ticket: APPSEC-70954
Contributor Checklist