Auto TraceΒΆ
Metaclass for automatic method tracing via OpenTelemetry.
ClassesΒΆ
CallerTraceMiddleware ΒΆ
Continues the caller's trace (traceparent, baggage) when FastAPI's request spans are off, which also turns off FastAPI reading those headers. A request span a host's own instrumentation started stays the parent.
AutoTracedMeta ΒΆ
Bases: type
Metaclass that automatically applies @traced_and_logged to all public methods.
This enables automatic OpenTelemetry span creation and debug logging for all method calls on classes using this metaclass.
Control via environment variable
FLOCK_AUTO_TRACE=true - Enable auto-tracing (default) FLOCK_AUTO_TRACE=false - Disable auto-tracing
Example
class Agent(metaclass=AutoTracedMeta): def execute(self, ctx, artifacts): # Automatically traced and logged ...
Methods:ΒΆ
__new__ ΒΆ
Create a new class with auto-traced methods.
Source code in src/flock/logging/auto_trace.py
Functions:ΒΆ
http_telemetry ΒΆ
http_telemetry() -> dict
FastAPI's own spans of the server's requests: at FLOCK_TRACE_LEVEL=all only.
continue_caller_traces ΒΆ
Below FLOCK_TRACE_LEVEL=all, agent work an HTTP request starts still joins the caller's trace.
skip_trace ΒΆ
Decorator to mark a method to skip auto-tracing.
Use this for methods that are called very frequently or are not interesting for debugging purposes.
Example
class Agent(metaclass=AutoTracedMeta): @skip_trace def _internal_helper(self): # Not traced ...
Source code in src/flock/logging/auto_trace.py
trace_level ΒΆ
trace_level(level: str)
Decorator: trace this method only at FLOCK_TRACE_LEVEL=level.
all marks Flock's internals, such as building and registering agents; a whole class sets __trace_level__ = "all" instead.