Skip to content

Send metric handles with telemetry - #406

Draft
cataphract wants to merge 3 commits into
glopes/telemetry-metric-handle-apifrom
glopes/telemetry-send-metric-handles
Draft

cataphract wants to merge 3 commits into
glopes/telemetry-metric-handle-apifrom
glopes/telemetry-send-metric-handles

Conversation

@cataphract

@cataphract cataphract commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Makes Telemetry send the metric handles of #404. counter::create, rate::create and distribution::create create a handle and register it with the running Telemetry:

auto requests = telemetry::counter::create<RequestTags>(
    {"waf.requests", "appsec", true}, {"waf_version:1.30.1"});
requests->record({true, Outcome::ok, rules_version}, 1);

The string-tagged functions still work. Nothing in dd-trace-cpp creates handles yet.

Stacked on #404.

Motivation

The handles of #404 record points, but nothing sends them. This PR connects them to the payloads:

Additional Notes

  • The registry is a member of Telemetry, found through the global instance. A handle created while telemetry is not running records values that are never sent, so create handles after telemetry::init.
  • The caller owns each handle. Telemetry holds only weak references, as in Add a metric handle API for telemetry #404.
  • sketch_b64 is standard base64 with padding, which is what the intake's Go decoder (base64.StdEncoding) reads. base64_encode gives the same output as Go's encoder, and its output decodes with sketches-go.
  • The new tests check that handle series reach generate-metrics and sketches. The full suite passes.

References

Jira ticket: APPSEC-70954

Contributor Checklist

  • I am the author of this pull request and I own it.
  • I reviewed every line of this pull request.
  • This pull request follows the Contributing Guidelines.

Raw distribution payloads grow with traffic. Like libdatadog, telemetry
will send DDSketches instead. This adds the sketch; it is not wired in.
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.
@pr-commenter

pr-commenter Bot commented Nov 14, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-14 01:36:18

Comparing candidate commit 106be1f in PR branch glopes/telemetry-send-metric-handles with baseline commit a66916b in branch glopes/telemetry-metric-handle-api.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 8 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

This branch has not been deployed

No deployments
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.

1 participant