Instrumentation: Capturing Without Friction
For tracing to be effective, it must be consistent and low-effort. SpanForge achieves this through a tracer abstraction and automatic instrumentation.
A typical integration uses a decorator:
@trace(kind="LLM", name="llm.completion")
def generate_summary(prompt):
return llm.generate(prompt)
When invoked, this function automatically creates a span, associates it with the active trace, records timing, and captures exceptions. Attributes such as token counts or latency can be attached without additional code.
Instrumentation scales with the system, rather than becoming a maintenance burden.
Lifecycle hooks provide controlled flexibility. They allow additional logic to be executed when spans are created or completed. For example, a hook might attach a user identifier, compute derived metrics, or enforce attribute requirements.