From 5824f728f69f402c6c9195a966acd6915a42d090 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 9 Jun 2026 13:24:35 -0400 Subject: [PATCH] Start OTEL collector in run_skill() default container runner The _default_run_container() function used by run_skill() never started the OTEL collector, so PodmanBackend.run() always received otel_port=None and no telemetry was collected. This meant _load_otel_cost() never found the JSONL file and cost data was never populated in verdicts. Start the collector before the container run and stop it in the finally block. The JSONL file is written to work_dir/_run/claude-otel.jsonl, which is exactly where _load_otel_cost() already looks. If the collector fails to start, log a warning and continue without telemetry. Co-Authored-By: Claude Signed-off-by: Emilien Macchi --- src/agentic_ci/skill.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/agentic_ci/skill.py b/src/agentic_ci/skill.py index b4201f6..777cffe 100644 --- a/src/agentic_ci/skill.py +++ b/src/agentic_ci/skill.py @@ -30,7 +30,7 @@ from agentic_ci.backends.podman import PodmanBackend from agentic_ci.harness import ClaudeCodeHarness -from agentic_ci.otel import parse_metrics +from agentic_ci.otel import parse_metrics, start_collector, stop_collector log = logging.getLogger(__name__) @@ -121,10 +121,23 @@ def _default_run_container( ) if verdict_path is not None: backend.verdict_path = verdict_path + + otel_proc = None + otel_port = None + if harness.supports_otel: + run_dir = Path(work_dir) / "_run" + run_dir.mkdir(parents=True, exist_ok=True) + try: + otel_proc, otel_port, _, _ = start_collector(str(run_dir)) + except Exception: + log.warning("Failed to start OTEL collector, continuing without telemetry") + try: backend.setup() - return backend.run(prompt, model=model) + return backend.run(prompt, model=model, otel_port=otel_port) finally: + if otel_proc: + stop_collector(otel_proc) backend.stop()