feat(profiling): implement Phase 2 deep instrumentation (#2851-#2857)#2869
Merged
feat(profiling): implement Phase 2 deep instrumentation (#2851-#2857)#2869
Conversation
This was
linked to
issues
Apr 10, 2026
Add profiling spans to all 5 subsystem crates and new core infrastructure for channel metrics and span-derived timings. Subsystem spans (all feature-gated, zero overhead when profiling disabled): - zeph-memory: memory.remember, memory.recall, memory.summarize, memory.graph_extract, memory.persona_extract, memory.cross_session, memory.vector_store (BoxFuture via .instrument()), memory.admission, memory.compaction_probe, memory.forgetting, memory.consolidation - zeph-tools: tool.execute_call, tool.shell, tool.file, tool.web_scrape, tool.search_code, tool.diagnostics; send_chunk excluded (hot path) - zeph-skills: skill.registry_load, skill.match, skill.matcher_sync, skill.qdrant_match, skill.generate, skill.hot_reload, skill.bm25_search - zeph-mcp: mcp.connect, mcp.connect_url, mcp.list_tools, mcp.call_tool, mcp.shutdown, mcp.tool_refresh, mcp.connect_all, mcp.shutdown_all - zeph-channels: channel.cli.recv/send, channel.telegram.recv/send New InstrumentedChannel infrastructure (zeph-core): - InstrumentedSender<T> / InstrumentedReceiver<T> (bounded mpsc) - InstrumentedUnboundedSender<T> (unbounded, sent count only) - Applied to skill_reload_rx and config_reload_rx in bootstrap - AtomicU64 counters, queue depth sampled every 16th send New MetricsBridge tracing layer (zeph-core): - Custom Layer using on_enter/on_exit accumulation for correct async timing - Watches agent.prepare_context, llm.chat, agent.tool_loop, agent.persist_message - Derives TurnTimings from span durations, replaces manual Instant::now() bookkeeping when profiling is active - on_new_span uses attrs.metadata().name() (zero-cost) before registry lock Closes #2851, #2852, #2853, #2854, #2855, #2856, #2857
fa0f127 to
c9d0544
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.
Summary
Phase 2 of the profiling and tracing system (epic #2846). Adds spans to all 5 subsystem crates, introduces
InstrumentedChannel<T>wrappers for channel-level metrics, and implementsMetricsBridge— a custom tracing layer that derivesTurnTimingsfrom span durations.InstrumentedSender<T>/InstrumentedReceiver<T>/InstrumentedUnboundedSender<T>(zero-cost when profiling disabled)MetricsBridgelayer withon_enter/on_exitaccumulation for correct async timing--features profilingskip_all, no PII in span fieldsCloses
Closes #2851, #2852, #2853, #2854, #2855, #2856, #2857
Part of #2846
Test plan
cargo +nightly fmt --check— PASScargo clippy --workspace --features profiling -- -D warnings— PASScargo build --workspace(no profiling) — PASScargo build --workspace --features profiling— PASScargo nextest run --workspace --features profiling --lib --bins— 7811 passed, 17 skipped[telemetry] enabled = true, backend = "local", verify spans visible in Perfetto UI (see.local/testing/playbooks/profiling.md)