Skip to content

Create a standardized error classification system that maps exceptions to semantic error types for consistent error reporting in traces #475

@psschwei

Description

@psschwei

Description:
Create a standardized error classification system that maps exceptions to semantic error types for consistent error reporting in traces.

Detailed Requirements:

  1. 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
  2. Create exception classifier:
    • classify_exception(exception) -> ErrorType
    • Handle provider-specific exceptions (OpenAI, Anthropic, etc.)
  3. Create helper for setting span status:
    • set_semantic_error(span, exception) - Sets status and error attributes
  4. Integrate with existing set_span_error() function
  5. 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:

  • All common exceptions mapped to semantic types
  • Span status correctly set on errors
  • Error type attribute added to spans
  • Provider-specific exceptions handled

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions