3 releases (1 stable)
Uses new Rust 2024
| 1.0.0 | Feb 9, 2026 |
|---|---|
| 0.9.91 | Feb 9, 2026 |
| 0.9.9 | Feb 9, 2026 |
#445 in Debugging
290KB
6.5K
SLoC
Observability Hooks API
fobserve provides production-oriented observability hooks for Fiddlesticks runtimes.
It offers ready-made tracing and metrics hook implementations across:
- provider operations (
fprovider) - tool execution lifecycle (
ftooling) - harness phase lifecycle (
fharness)
Responsibilities
- Emit structured tracing events for provider/tool/harness phases
- Emit counters and histograms for operational metrics
- Provide panic-safe wrappers so hook code cannot take down runtime execution
fobserve does not:
- decide retry/tool/phase policy (
fprovider,fchat,fharnessown policy) - ship a metrics exporter or tracing subscriber (application owns wiring)
Add dependency
[dependencies]
fobserve = { path = "../fobserve" }
fchat = { path = "../fchat" }
fharness = { path = "../fharness" }
ftooling = { path = "../ftooling" }
Core types
TracingObservabilityHooksMetricsObservabilityHooksSafeProviderHooks<H>SafeToolHooks<H>SafeHarnessHooks<H>
Module layout
tracing_hooks:TracingObservabilityHooksimplementations for provider/tool/harness hooksmetrics_hooks:MetricsObservabilityHooksimplementations for provider/tool/harness hookssafe_hooks: panic-isolating wrappers (SafeProviderHooks,SafeToolHooks,SafeHarnessHooks)lib: crate exports and prelude
Hook coverage
- Provider: attempt start, retry scheduled, success, failure
- Tool runtime: execution start, success, failure (with elapsed time)
- Harness: phase start, success, failure (initializer/task-iteration)
Production-safe wrappers
Use Safe*Hooks wrappers when you need strong isolation from observer panics.
SafeProviderHookswrapsProviderOperationHooksSafeToolHookswrapsToolRuntimeHooksSafeHarnessHookswrapsHarnessRuntimeHooks
Each wrapper catches panics in hook callbacks and suppresses them so core runtime flows continue.
End-to-end wiring example
use std::sync::Arc;
use fchat::ChatService;
use fharness::Harness;
use fobserve::{
MetricsObservabilityHooks, SafeHarnessHooks, SafeProviderHooks, SafeToolHooks,
TracingObservabilityHooks,
};
use ftooling::DefaultToolRuntime;
let provider_hooks = Arc::new(SafeProviderHooks::new(TracingObservabilityHooks));
let tool_hooks = Arc::new(SafeToolHooks::new(MetricsObservabilityHooks));
let harness_hooks = Arc::new(SafeHarnessHooks::new(TracingObservabilityHooks));
let tool_runtime = DefaultToolRuntime::new(tool_registry).with_hooks(tool_hooks);
let chat = ChatService::builder(Arc::clone(&provider))
.provider_operation_hooks(provider_hooks)
.tool_runtime(Arc::new(tool_runtime))
.build();
let harness = Harness::builder(memory)
.provider(provider)
.hooks(harness_hooks)
.build()?;
let _ = (chat, harness);
# Ok::<(), fharness::HarnessError>(())
Notes
fobserveintentionally emits generic metric names with labels so apps can map dashboards/alerts per deployment.tracing/metricsoutput requires app-level subscriber/recorder setup.
Testing
fobserve includes unit tests that:
- smoke-test all tracing and metrics callbacks
- verify safe wrappers delegate when inner hooks succeed
- verify safe wrappers swallow panics from inner hooks
Dependencies
~36–51MB
~736K SLoC