Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions