nat.observability.processor.processor#
Attributes#
Classes#
Generic protocol for processors that can convert between types in export pipelines. |
Module Contents#
- InputT#
- OutputT#
- class Processor#
Bases:
Generic[InputT,OutputT],nat.observability.mixin.type_introspection_mixin.TypeIntrospectionMixin,abc.ABCGeneric protocol for processors that can convert between types in export pipelines.
Processors are the building blocks of processing pipelines in exporters. They can transform data from one type to another, enabling flexible data processing chains.
The generic types work as follows: - InputT: The type of items that this processor accepts - OutputT: The type of items that this processor produces
Key Features: - Type-safe transformations through generics - Type introspection capabilities via TypeIntrospectionMixin - Async processing support - Chainable in processing pipelines
Inheritance Structure: - Inherits from TypeIntrospectionMixin for type introspection capabilities - Implements Generic[InputT, OutputT] for type safety - Abstract base class requiring implementation of process()
- Example:
class SpanToOtelProcessor(Processor[Span, OtelSpan]): async def process(self, item: Span) -> OtelSpan: return convert_span_to_otel(item)
- Note:
Processors are typically added to ProcessingExporter instances to create transformation pipelines. The exporter validates type compatibility between chained processors.
- _signature_method = 'process'#
- abstractmethod process(item: InputT) OutputT#
- Async:
Process an item and return a potentially different type.
- Args:
item (InputT): The item to process
- Returns:
OutputT: The processed item