Manual Tracing
Tracing operations
See the Quick Start for instructions on installing and configuring the Graphsignal tracer.
Python
To measure and monitor operations that are not automatically instrumented, e.g. tool calls, wrap the code with trace()
method or use @trace_function
decorator.
You can also record sub-operations to visualize operation timeline and latency breakdown.
with graphsignal.trace('inference') as op_span:
span.set_counter('prompt_tokens', prompt_tokens)
span.set_counter('completion_tokens', completion_tokens)
with span.trace('model-cold-boot') as subop_span:
...
@graphsignal.trace_function
def my_function():
...
Exceptions
Python
For auto-instrumented libraries, or when using @trace_function
decorator, trace()
method with with
context manager or callbacks, exceptions are automatically recorded. For other cases, use Span.add_exception
.