Repository navigation
feat(telemetry): opt-in telemetry for headless binaries (mecatequi, mecak8s) - #393
Merged
Merged
Conversation
JAORMX
force-pushed
the
feat/343-headless-telemetry
branch
2 times, most recently
from
August 5, 2026 21:08
2de4e30 to
94330cc
Compare
…ecak8s) (#343) The headless mains deliberately wired Sink/ToolCallRecorder/metrics to nil, leaving a factory running many one-shot invocations with no fleet-level telemetry beyond exit codes and JSONL event files. Reuse the existing internal/adapter/telemetry pipeline (the SAME Setup + NewMetrics + WithRole role-scoper path mecated uses) behind opt-in, default-off flags so the no-telemetry posture stays byte-identical. - internal/adapter/telemetry: add an optional OTLP METRICS push reader (PeriodicReader over otlpmetricgrpc/http) alongside the always-on prometheus reader, gated on new OTLPConfig.Metrics* fields. Existing scrape-only callers are untouched. - mecatequi (short-lived one-shot, scrape does not fit): opt-in --otlp-* / --otlp-metrics-* push flags with an explicit flush-before-exit bounded by --otlp-shutdown-timeout so a dead collector can't hang CI. - mecak8s (long-lived server, scrape fits): opt-in --metrics-addr loopback /metrics listener (non-loopback rejected fail-closed per ADR 0018) plus opt-in OTLP push twin for non-scrape deployments. - internal/cliconfig: shared HeadlessTelemetry helper (Rule of Three across the two new mains) + a canonical IsLoopbackAddr replacing the duplicated loopback checks in mecated and mecak8s. - Reuses the existing mecatl.* instruments (no new metrics); per-run token counters ride EvResult.Usage. Labels stay the issue-#47 closed Role set. Cost counter deferred to #192 (pricing deliberately unparsed). - ADR 0097 + ADR 0027 List-1 inventory rows + usage/user-docs. Co-Authored-By: Juan Antonio Osorio <[email protected]>
…ck provider The scrape e2e called app.Build without --mock, so it depended on a real provider key in the environment. It passed locally (a key was present) but failed in CI with "no LLM provider available". Pin it to --mock like the sibling telemetry tests so it is hermetic and offline. Co-Authored-By: Juan Antonio Osorio <[email protected]>
JAORMX
force-pushed
the
feat/343-headless-telemetry
branch
from
August 6, 2026 03:56
94330cc to
1909e9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #343. Part of the dark-factory epic (stacklok/stacklok-epics#297), Phase 3.
Gap
mecatequi and mecak8s deliberately wired
Sink/ToolCallRecorder/metrics to nil — no Prometheus, no OTel. A factory running many one-shot invocations got no fleet-level telemetry beyond exit codes and JSONL event files.What this does
Reuses the existing
internal/adapter/telemetrypipeline (the SAMESetup+NewMetrics+WithRolerole-scoper path mecated already uses) behind opt-in, default-off flags. The no-telemetry posture stays byte-identical (Config.Sink == nilpinned by test).internal/adapter/telemetry— new optional OTLP metrics push reader (PeriodicReaderoverotlpmetricgrpc/otlpmetrichttp) alongside the always-on prometheus reader, gated on newOTLPConfig.Metrics*fields. Existing scrape-only callers untouched.--otlp-*/--otlp-metrics-*push flags with an explicit flush-before-exit bounded by--otlp-shutdown-timeoutso a dead collector can't hang CI.--metrics-addrloopback/metricslistener (non-loopback rejected fail-closed per ADR 0018 decision 6) + opt-in OTLP push twin for non-scrape deployments.internal/cliconfig— sharedHeadlessTelemetryhelper (Rule of Three across the two new mains) + a canonicalIsLoopbackAddrreplacing the duplicated loopback checks in mecated and mecak8s.Metrics / labels
Reuses the existing
mecatl.*instruments — adds none. Per-run token counters rideEvResult.Usage(mecatl.tokens), run outcomes viamecatl.runs. Labels stay the issue-#47 closedRole*set — no session-id / model-id / free-text cardinality. Amecatl.costcounter is deferred to #192 (pricing deliberately unparsed inprovidercatalog).Flags
--otlp-endpoint--otlp-endpoint""(off)--otlp-protocol--otlp-protocolgrpc--otlp-insecure--otlp-insecurefalse--otlp-metrics-endpoint--otlp-metrics-endpoint""(off)--otlp-metrics-protocol--otlp-metrics-protocolgrpc--otlp-shutdown-timeout--otlp-shutdown-timeout5s--metrics-addr(loopback-only)""(off)Coverage
internal/adapter/telemetry/otlp_metrics_test.go— scrape-only byte-identical regression guard; push+flush-on-shutdown to a fake collector; shutdown bounded by ctx; bad-protocol fail-closed.internal/cliconfig/telemetry_test.go+loopback_test.go— no-endpoint no-op; loopback gate accepts/rejections.cmd/mecatequi/telemetry_test.go— default-nil posture; fullrealMaine2e pushesmecatl.runs/mecatl.eventsto a fake collector; shutdown-timeout bounded against a stalling collector (fails if the bound is removed).cmd/mecak8s/telemetry_test.go— default-nil posture;/metricsserved on loopback through the fullserve()path; non-loopback rejected at parse; OTLP-push e2e throughserve()+ SIGTERM flush.Docs
ADR 0097; ADR 0027 List-1 inventory rows; usage + user-docs for both binaries;
llms.txtregenerated.Verification
task build,task lint(0 issues, all modules),task test(root + engine + standalone + provider),go run ./cmd/mecademo,task docs && task docs:check,task site:build— all green.Follow-ups (noted in ADR 0097, out of scope here)
cliconfig.HeadlessTelemetry.mecatl.costper-run cost counter (blocked on Provide native mechanisms for cost tracking #192).Co-Authored-By: Juan Antonio Osorio [email protected]