Skip to content

Add support for Sentry backend #7

@nirga

Description

@nirga

Description

Add support for Sentry as an observability backend, enabling users to query OpenTelemetry traces from Sentry Performance Monitoring.

Motivation

Sentry is widely adopted for error tracking and performance monitoring, with growing support for distributed tracing via OpenTelemetry. Adding Sentry backend support would enable users to leverage this MCP server for AI-powered analysis of traces alongside error data in Sentry.

Implementation Requirements

1. Backend Implementation

  • Create src/openllmetry_mcp/backends/sentry.py following the abstract interface in backends/base.py
  • Implement the following methods:
    • search_traces() - Query traces using Sentry Discover/Traces API
    • get_trace() - Retrieve full trace details
    • list_services() - List available services/projects
    • get_aggregated_usage() - Aggregate token usage metrics

2. Configuration

  • Add sentry as a backend type option
  • Required configuration:
    • BACKEND_URL: Sentry instance URL (e.g., https://sentry.io or self-hosted URL)
    • BACKEND_API_KEY: Sentry auth token with trace read permissions
    • SENTRY_ORG: Organization slug (required)
    • SENTRY_PROJECT: Project slug (optional, can query across org)
  • Update .env.example with Sentry configuration example

3. API Integration

Reference Sentry APIs:

4. OpenLLMetry Support

Ensure proper parsing of OpenLLMetry semantic conventions (gen_ai.* attributes) from Sentry trace spans and transaction data.

5. Documentation

  • Add Sentry backend configuration to README.md
  • Include Claude Desktop integration example
  • Document both SaaS and self-hosted configurations
  • Add troubleshooting section for common Sentry connection issues
  • Note any limitations vs other backends (e.g., trace retention, query capabilities)

6. Testing

  • Add unit tests in tests/backends/test_sentry.py
  • Test trace querying with Sentry's discover query syntax
  • Test filtering, aggregation, and error correlation
  • Test error handling and authentication

Example Configuration

BACKEND_TYPE=sentry
BACKEND_URL=https://sentry.io
BACKEND_API_KEY=sntrys_abc123...
SENTRY_ORG=my-org
SENTRY_PROJECT=my-llm-app

References

Additional Considerations

  • Sentry's trace model may differ from pure OpenTelemetry backends (transactions vs spans)
  • Consider integration with Sentry's error tracking for enhanced debugging
  • May need to handle Sentry's sampling/retention policies differently

Acceptance Criteria

  • Sentry backend implementation complete
  • All abstract methods implemented
  • Configuration documented (SaaS and self-hosted)
  • Tests passing
  • README updated with Sentry examples
  • Works with Claude Desktop integration
  • Document any backend-specific limitations

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershelp wantedExtra attention is neededsourcesSupport for additional observability platforms

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions