Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Pin delta temporality for Claude Code metric exports

Claude8ee8a86d49d0
diff --git a/cli/beacon/internal/ci/harness.go b/cli/beacon/internal/ci/harness.go
index 637c42ad..9543053f 100644
--- a/cli/beacon/internal/ci/harness.go
+++ b/cli/beacon/internal/ci/harness.go
@@ -30,6 +30,9 @@ func ClaudeEnv(base []string, endpoint string) []string {
env["CLAUDE_CODE_ENABLE_TELEMETRY"] = "1"
env["OTEL_LOGS_EXPORTER"] = "otlp"
env["OTEL_METRICS_EXPORTER"] = "otlp"
+ // Delta temporality keeps token usage counters per-interval so downstream
+ // aggregation can sum datapoints without deduping cumulative series.
+ env["OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"] = "delta"
env["OTEL_EXPORTER_OTLP_PROTOCOL"] = "grpc"
env["OTEL_EXPORTER_OTLP_ENDPOINT"] = endpoint
delete(env, "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT")
diff --git a/cli/beacon/internal/ci/harness_test.go b/cli/beacon/internal/ci/harness_test.go
index f4ff818e..cc5ac928 100644
--- a/cli/beacon/internal/ci/harness_test.go
+++ b/cli/beacon/internal/ci/harness_test.go
@@ -12,6 +12,7 @@ func TestClaudeEnvIncludesPromptLogging(t *testing.T) {
for _, want := range []string{
"CLAUDE_CODE_ENABLE_TELEMETRY=1",
"OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317",
+ "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta",
"OTEL_LOG_USER_PROMPTS=1",
} {
if !strings.Contains(env, want) {
diff --git a/cli/beacon/internal/endpoint/harness/harness.go b/cli/beacon/internal/endpoint/harness/harness.go
index b3544549..9c7203fa 100644
--- a/cli/beacon/internal/endpoint/harness/harness.go
+++ b/cli/beacon/internal/endpoint/harness/harness.go
@@ -306,6 +306,9 @@ func ConfigureClaude(opts ConfigureOptions) (string, error) {
env["CLAUDE_CODE_ENABLE_TELEMETRY"] = "1"
env["OTEL_LOGS_EXPORTER"] = "otlp"
env["OTEL_METRICS_EXPORTER"] = "otlp"
+ // Delta temporality keeps token usage counters per-interval so downstream
+ // aggregation can sum datapoints without deduping cumulative series.
+ env["OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"] = "delta"
env["OTEL_EXPORTER_OTLP_PROTOCOL"] = "grpc"
env["OTEL_EXPORTER_OTLP_ENDPOINT"] = opts.Endpoint
env["OTEL_LOG_USER_PROMPTS"] = "1"
diff --git a/cli/beacon/internal/endpoint/harness/harness_test.go b/cli/beacon/internal/endpoint/harness/harness_test.go
index 01a1deff..b5bf83e2 100644
--- a/cli/beacon/internal/endpoint/harness/harness_test.go
+++ b/cli/beacon/internal/endpoint/harness/harness_test.go
@@ -66,9 +66,10 @@ func TestConfigureClaudeWritesTelemetryEnvAndBackup(t *testing.T) {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_METRICS_EXPORTER": "otlp",
- "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
- "OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:4317",
- "OTEL_LOG_USER_PROMPTS": "1",
+ "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": "delta",
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:4317",
+ "OTEL_LOG_USER_PROMPTS": "1",
} {
if got := env[key]; got != want {
t.Fatalf("env[%s] = %q, want %q; env=%#v", key, got, want, env)