azure.ai.projects.telemetry package¶
- azure.ai.projects.telemetry.trace_function(span_name: str | None = None)[source]¶
A decorator for tracing function calls using OpenTelemetry.
This decorator handles various data types for function parameters and return values, and records them as attributes in the trace span. The supported data types include: - Basic data types: str, int, float, bool - Collections: list, dict, tuple, set
Special handling for collections: - If a collection (list, dict, tuple, set) contains nested collections, the entire collection is converted to a string before being recorded as an attribute. - Sets and dictionaries are always converted to strings to ensure compatibility with span attributes.
Object types are omitted, and the corresponding parameter is not traced.
- Parameters:
span_name (Optional[str]) – The name of the span. If not provided, the function name is used.
- Returns:
The decorated function with tracing enabled.
- Return type:
Callable