Skip to main content

Tracing & Telemetry

The tracing module provides utilities for registering and managing OpenTelemetry-compatible tracing for your projects, including project registration, span attributes, and tracer provider configuration.

register Function

Registers a new tracing provider for your project and configures telemetry for experiment or observe runs.
Arguments:
  • project_name (Optional[str]): Name of the project. If not provided, will be read from environment variables.
  • project_type (Optional[ProjectType]): Type of the project (EXPERIMENT or OBSERVE). Default: EXPERIMENT.
  • project_version_name (Optional[str]): Version name for the project.
  • eval_tags (Optional[List[EvalTag]]): List of evaluation tags.
  • metadata (Optional[Dict[str, Any]]): Additional metadata for the project.
  • batch (bool): Whether to use batch span processing. Default: False.
  • set_global_tracer_provider (bool): If True, sets this provider as the global OpenTelemetry tracer provider.
  • headers (Optional[Dict[str, str]]): Additional headers for the exporter.
  • verbose (bool): If True, prints configuration details.
Returns:
  • _TracerProvider: The configured tracer provider.
Raises:
  • ValidationError: If arguments are invalid or duplicate custom eval names are provided.

TracerProvider Class

An extension of opentelemetry.sdk.trace.TracerProvider with Future AGI aware defaults.
Arguments:
  • endpoint (str, optional): The collector endpoint to which spans will be exported.
  • verbose (bool): If True, configuration details will be printed to stdout.
Methods:
  • add_span_processor(...): Registers a new SpanProcessor for this TracerProvider.

Span and Message Attribute Constants

The following classes provide constants for span and message attributes used in tracing:
  • SpanAttributes
  • MessageAttributes
  • MessageContentAttributes
  • ImageAttributes
  • AudioAttributes
  • DocumentAttributes
  • RerankerAttributes
  • EmbeddingAttributes
  • ToolCallAttributes
  • ToolAttributes
Each class contains string constants for OpenTelemetry span attributes, such as:
Refer to the SDK source or inline docstrings for the full list of available attributes.

Enum Types

The tracing module also provides several enums for project and span types:
  • ProjectType: EXPERIMENT, OBSERVE
  • EvalTagType
  • EvalSpanKind
  • EvalName
  • Endpoints
  • FiSpanKindValues
  • FiMimeTypeValues
  • FiLLMSystemValues
  • FiLLMProviderValues

Example Usage with LangChain Instrumentor