fix(otel): cumulative metric temporality + metricIntervalMs knob (real metrics-export fix)
This commit is contained in:
parent
609438a889
commit
af10a4bfef
3 changed files with 64 additions and 10 deletions
|
|
@ -250,6 +250,17 @@ in
|
|||
Host-driven via `services.hyperhive.otel.extraResourceAttributes`.
|
||||
'';
|
||||
};
|
||||
|
||||
metricIntervalMs = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.ints.positive;
|
||||
default = null;
|
||||
internal = true;
|
||||
description = ''
|
||||
Metric export interval in milliseconds, set as
|
||||
`OTEL_METRIC_EXPORT_INTERVAL`. Null leaves Claude Code's 60s
|
||||
default. Host-driven via `services.hyperhive.otel.metricIntervalMs`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
options.hyperhive.allowedRecipients = lib.mkOption {
|
||||
|
|
@ -1735,16 +1746,28 @@ in
|
|||
# Claude Code's native OpenTelemetry is env-driven; the harness
|
||||
# spawns `claude` as a child which inherits this unit's env, so
|
||||
# setting these here is all it takes to export per-agent stats.
|
||||
otelEnv = lib.optionalAttrs otel.enable {
|
||||
CLAUDE_CODE_ENABLE_TELEMETRY = "1";
|
||||
OTEL_METRICS_EXPORTER = "otlp";
|
||||
OTEL_LOGS_EXPORTER = "otlp";
|
||||
# Route traces to OTLP too so any spans Claude Code emits land
|
||||
# at the configured collector rather than a default exporter.
|
||||
OTEL_TRACES_EXPORTER = "otlp";
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL = otel.protocol;
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT = otel.endpoint;
|
||||
};
|
||||
otelEnv = lib.optionalAttrs otel.enable (
|
||||
{
|
||||
CLAUDE_CODE_ENABLE_TELEMETRY = "1";
|
||||
OTEL_METRICS_EXPORTER = "otlp";
|
||||
OTEL_LOGS_EXPORTER = "otlp";
|
||||
# Route traces to OTLP too so any spans Claude Code emits land
|
||||
# at the configured collector rather than a default exporter.
|
||||
OTEL_TRACES_EXPORTER = "otlp";
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL = otel.protocol;
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT = otel.endpoint;
|
||||
# Force CUMULATIVE metric temporality. Claude Code defaults to
|
||||
# DELTA, which Prometheus/Mimir-family backends (the common case,
|
||||
# incl. grafana-lgtm) silently drop unless a deltatocumulative
|
||||
# processor is wired — so delta = "logs arrive, metrics vanish".
|
||||
# Cumulative is what those backends ingest natively. Verified:
|
||||
# a delta export never registers the metric name; cumulative does.
|
||||
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = "cumulative";
|
||||
}
|
||||
// lib.optionalAttrs (otel.metricIntervalMs != null) {
|
||||
OTEL_METRIC_EXPORT_INTERVAL = toString otel.metricIntervalMs;
|
||||
}
|
||||
);
|
||||
# When OTEL is on, wrap the harness launch so (1) the bearer-token
|
||||
# header is read from the systemd credential at start (never in the
|
||||
# nix store or argv) and (2) the resource attributes are assembled
|
||||
|
|
|
|||
Loading…
Reference in a new issue