Module: tff.profiler

Stay organized with collections Save and categorize content based on your preferences.

Utility functions for instrumenting code with timing and tracing data.

This module provides several functions for preserving trace context across various boundaries, namely between asyncio and regular python code:

  • wrap_coroutine_in_trace_context wraps a coroutine such that it inherits the ambient trace context. It should be used when executing a coroutine that should inherit trace context from the current thread or task.
  • EventLoops should use the Task factory provided by propagate_trace_context_task_factory by calling set_task_factory(propagate_trace_context_task_factory).

Classes

class Generator

class LoggingTracingProvider: Implements TracingProvider and outputs the results via logging.

class ThreadLocalSpanYields: The span set for the current thread.

class TracedFunctionReturned: The traced function returned successfully.

class TracedFunctionThrew: The traced function threw an exception.

class TracedSpan: The trace was wrapping a non-function span.

class TracingProvider: Abstract base class for tracers.

Functions

add_tracing_provider(...): Add to the global list of tracing providers.

propagate_trace_context_task_factory(...): Creates a new task on loop to run coro, inheriting current spans.

set_tracing_providers(...): Set the global list of tracing providers, replacing any existing.

span(...): Creates a ContextManager that wraps the code in question with a span.

trace(...): Delegates to the current global TracingProvider.

with_trace_context_from_rpc(...): Attempts to pick up the trace context from the receiving RPC call.

wrap_coroutine_in_current_trace_context(...): Wraps the coroutine in the currently active span.

wrap_rpc_in_trace_context(...): Attempts to record the trace context into the enclosed RPC call.

Type Aliases

SpanYields

TraceResult

T Instance of typing.TypeVar