feat(tracing): TraceSink network sink (file + HTTP collector) — v0.2.0#3
Conversation
agent_core/tracing/sink.py: NullSink, JsonlFileSink, HttpSink (stdlib urllib POST), MultiSink, and sink_from_env(flag_env) building file and/or HTTP sinks from env ({flag}_COLLECTOR_URL alongside the existing {flag}_PATH; backward-compatible). Best-effort: emit() never raises. Lets producers ship TraceEvents to a central collector (the right fit for the read-only knowledge-mcp container) instead of dead-end local files. Contracts stay dependency-light (stdlib only).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b98852b667
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def emit(self, event: TraceEvent) -> bool: | ||
| delivered = False | ||
| for sink in self.sinks: | ||
| if sink.emit(event): |
There was a problem hiding this comment.
Catch per-sink failures in MultiSink
When MultiSink is used with a custom sink (or a built-in sink with an unexpected bug), an exception from sink.emit(event) propagates and prevents later sinks from receiving the event. That breaks the documented best-effort contract that emit() never raises; for example, MultiSink([raising_sink, JsonlFileSink(...)]) would lose the file delivery instead of returning whether any sink succeeded. Wrap each per-sink emit in try/except and continue fanout.
Useful? React with 👍 / 👎.
Adds
agent_core/tracing/sink.pyso producers can ship TraceEvents to a centralcollector, not just write dead-end local JSONL.
NullSink,JsonlFileSink,HttpSink(stdliburllibPOST),MultiSink.sink_from_env(flag_env): builds file and/or HTTP sinks from env — adds{flag}_COLLECTOR_URL(+ optional{flag}_COLLECTOR_TOKEN) alongside the existing{flag}_PATH. Backward-compatible with the current file-only emitters.emit()never raises. stdlib-only — core stays dependency-light.This is the foundation for the trace collector (C2). The HTTP sink is the right fit for the
read-only knowledge-mcp container (no writable-volume hack). Bumped to 0.2.0.
ruff + mypy clean; 32 tests pass.
🤖 Generated with Claude Code