observability.processor.trace_conversion.span_to_dfw#
Attributes#
Functions#
|
Extract string value from enum or literal type safely. |
|
Create a TraceContainer from a span for schema detection and conversion. |
|
Convert a span to Data Flywheel record using registered trace adapters. |
Module Contents#
- logger#
- _get_string_value(value: Any) str#
Extract string value from enum or literal type safely.
- Args:
value (Any): Could be an Enum, string, or other type
- Returns:
str: String representation of the value
- get_trace_container(
- span: nat.data_models.span.Span,
- client_id: str,
Create a TraceContainer from a span for schema detection and conversion.
Extracts trace data from span attributes and creates a TraceContainer where Pydantic’s discriminated union will automatically detect the correct trace source schema type.
- Args:
span (Span): The span containing trace attributes to extract client_id (str): The client ID to include in the trace source data
- Returns:
TraceContainer: Container with automatically detected source type and original span
- Raises:
ValueError: If span data doesn’t match any registered trace source schemas
- span_to_dfw_record(
- span: nat.data_models.span.Span,
- to_type: type[pydantic.BaseModel],
- client_id: str,
Convert a span to Data Flywheel record using registered trace adapters.
Creates a TraceContainer from the span, automatically detects the trace source type via Pydantic schema matching, then uses the registered converter to transform it to the specified target type.
- Args:
span (Span): The span containing trace data to convert. to_type (type[BaseModel]): Target Pydantic model type for the conversion. client_id (str): Client identifier to include in the trace data.
- Returns:
BaseModel: Converted record of the specified type.
- Raises:
- ValueError: If no converter is registered for the detected source type -> target type,
or if the conversion fails.