Description:
Create a standardized error classification system that maps exceptions to semantic error types for consistent error reporting in traces.
Detailed Requirements:
- Define semantic error types in
mellea/telemetry/errors.py:
rate_limit - Rate limiting errors
timeout - Request timeouts
content_policy - Content policy violations
auth - Authentication errors
invalid_request - Bad request errors
transport_error - Network errors
server_error - Provider server errors
validation_error - Mellea validation failures
tool_error - Tool execution errors
- Create exception classifier:
classify_exception(exception) -> ErrorType
- Handle provider-specific exceptions (OpenAI, Anthropic, etc.)
- Create helper for setting span status:
set_semantic_error(span, exception) - Sets status and error attributes
- Integrate with existing
set_span_error() function
- Add
error.type span attribute with semantic type
Files to Create:
mellea/telemetry/errors.py
Files to Modify:
mellea/telemetry/__init__.py - Export error utilities
mellea/telemetry/backend_instrumentation.py - Use semantic errors
Error Type Attributes:
| Attribute |
Description |
error.type |
Semantic error category |
error.message |
Exception message |
exception.type |
Python exception class name |
Acceptance Criteria:
Description:
Create a standardized error classification system that maps exceptions to semantic error types for consistent error reporting in traces.
Detailed Requirements:
mellea/telemetry/errors.py:rate_limit- Rate limiting errorstimeout- Request timeoutscontent_policy- Content policy violationsauth- Authentication errorsinvalid_request- Bad request errorstransport_error- Network errorsserver_error- Provider server errorsvalidation_error- Mellea validation failurestool_error- Tool execution errorsclassify_exception(exception) -> ErrorTypeset_semantic_error(span, exception)- Sets status and error attributesset_span_error()functionerror.typespan attribute with semantic typeFiles to Create:
mellea/telemetry/errors.pyFiles to Modify:
mellea/telemetry/__init__.py- Export error utilitiesmellea/telemetry/backend_instrumentation.py- Use semantic errorsError Type Attributes:
error.typeerror.messageexception.typeAcceptance Criteria: