ClassDecorators

Base OpenTelemetry tracing decorators and utilities for Pipecat.

This module provides class and method level tracing capabilities similar to the original NVIDIA implementation.

class pipecat.utils.tracing.class_decorators.AttachmentStrategy(*values)[source]

Bases: Enum

Controls how spans are attached to the trace hierarchy.

CHILD

Attached to class span if no parent, otherwise to parent.

LINK

Attached to class span with link to parent.

NONE

Always attached to class span regardless of context.

CHILD = 1
LINK = 2
NONE = 3
class pipecat.utils.tracing.class_decorators.Traceable(name, **kwargs)[source]

Bases: object

Base class for objects that can be traced with OpenTelemetry.

Provides the foundational tracing capabilities used by @traced methods.

Parameters:

name (str)

property meter

Returns the OpenTelemetry meter instance.

Returns:

The OpenTelemetry meter instance for this object.

Return type:

Meter

pipecat.utils.tracing.class_decorators.traced(func=None, *, name=None, attachment_strategy=AttachmentStrategy.CHILD)[source]

Adds tracing to an async function in a Traceable class.

Parameters:
  • func (Callable | None) – The async function to trace.

  • name (str | None) – Custom span name. Defaults to function name.

  • attachment_strategy (AttachmentStrategy) – How to attach this span (CHILD, LINK, NONE).

Returns:

Wrapped async function with tracing.

Raises:
  • RuntimeError – If used in a class not inheriting from Traceable.

  • ValueError – If used on a non-async function.

Return type:

Callable

pipecat.utils.tracing.class_decorators.traceable(cls)[source]

Makes a class traceable for OpenTelemetry.

Creates a new class that inherits from both the original class and Traceable, enabling tracing for class methods.

Parameters:

cls (C) – The class to make traceable.

Returns:

A new class with tracing capabilities.

Return type:

C