- Application Trace (mellea.application) - User-facing operations
- Backend Trace (mellea.backend) - LLM backend interactions
- MELLEA_TRACE_APPLICATION: Enable/disable application tracing (default: false)
- MELLEA_TRACE_BACKEND: Enable/disable backend tracing (default: false)
- MELLEA_TRACE_CONTENT: Capture prompt/response content in spans (default: false). Content may include PII — enable only in controlled environments. Also recognised: OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT (OTel standard).
- OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint for trace export
- OTEL_SERVICE_NAME: Service name for traces (default: mellea)
Functions
FUNC is_application_tracing_enabled
- True if application tracing has been enabled via the
MELLEA_TRACE_APPLICATIONenvironment variable.
FUNC is_backend_tracing_enabled
- True if backend tracing has been enabled via the
MELLEA_TRACE_BACKENDenvironment variable.
FUNC is_content_tracing_enabled
- True if enabled via
MELLEA_TRACE_CONTENTor OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT.
FUNC add_span_event
span: The span object (may be None if tracing is disabled).name: Event name.attributes: Optional event attributes.
FUNC trace_application
name: Name of the span.**attributes: Additional attributes to add to the span.
FUNC trace_backend
name: Name of the span.**attributes: Additional attributes to add to the span.
FUNC start_backend_span
name: Name of the span**attributes: Additional attributes to add to the span
- The span object if tracing is enabled, otherwise None
FUNC end_backend_span
span: The span object to end
FUNC set_span_attribute
span: The span object (may be None if tracing is disabled)key: Attribute keyvalue: Attribute value
FUNC set_span_error
span: The span object (may be None if tracing is disabled)exception: The exception to record
FUNC set_span_status_error
set_span_error in these cases would create a misleading recorded
exception event in OTEL traces.
Args:
span: The span object (may be None if tracing is disabled)description: Human-readable reason for the failure.