Skip to main content

Module datadog_push

Module datadog_push 

Source
Expand description

Agentless Datadog export (GL #401, setup path B).

Pushes the metrics-contract series straight to the Datadog Metrics API v2 (POST /api/v2/series, DD-API-KEY header) — no local Agent, no OTel Collector. Strictly opt-in: both LEAN_CTX_DATADOG_PUSH=1 and DD_API_KEY must be set; a stray DD_API_KEY from another tool never turns on egress by itself.

Counter semantics: Datadog v2 count points are per-interval deltas, not cumulative totals. The pusher keeps the last pushed totals in-process and submits deltas; the first cycle only records the baseline (submitting a lifetime total as one interval would spike every graph). Gauges go out on every cycle, including the first.

Tag policy is identical to the lean_ctx_info series: five bounded tags (project, profile, agent_role, model, version) attached to every series — bounded values, so Datadog custom-metric cardinality stays flat.

Functions§

enabled
True when the operator explicitly enabled the push exporter.
push_once
Build and submit one batch. Returns the number of series sent.
spawn_if_enabled
Spawn the background push loop if (and only if) the operator opted in. Called from long-running entry points (dashboard server). Returns whether the loop was started.