Skip to content

Enable metrics export to external observability systems via Prometheus scrape endpoint and/or OTLP metrics protocol #466

Closed

Description

@psschwei

Description:
Enable metrics export to external observability systems via Prometheus scrape endpoint and/or OTLP metrics protocol.

Detailed Requirements:

  1. Add OTLP metrics exporter configuration:
    • Uses existing OTEL_EXPORTER_OTLP_ENDPOINT or separate OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
    • Configure PeriodicExportingMetricReader with configurable interval
  2. Add optional Prometheus exporter:
    • MELLEA_METRICS_PROMETHEUS_PORT - Port for scrape endpoint
    • Uses opentelemetry-exporter-prometheus package
  3. Support multiple exporters simultaneously
  4. Add configuration validation and helpful error messages

Files to Modify:

  • mellea/telemetry/metrics.py - Add exporter configuration
  • pyproject.toml - Add prometheus exporter to optional deps

Dependencies to Add:

opentelemetry-exporter-prometheus>=0.40b0  # Optional

Environment Variables:

Variable Default Description
MELLEA_METRICS_OTLP false Enable OTLP metrics export
MELLEA_METRICS_PROMETHEUS_PORT - Port for Prometheus scrape (enables if set)
MELLEA_METRICS_EXPORT_INTERVAL 60 Export interval in seconds

Acceptance Criteria:

  • OTLP exporter sends metrics to configured endpoint
  • Prometheus endpoint exposes metrics in Prometheus format
  • Multiple exporters can run simultaneously
  • Graceful handling when exporters fail

Activity

  1. ajbozarth commented on Feb 26, 2026

    @ajbozarth
    Member

    Per suggestion from @serjikibm I will be picking up this sub-issue next before continuing the add more metrics so we can make sure that metrics export functionality works for the next release even if all the metrics are not yet implemented

  2. self-assigned this
    on Feb 26, 2026
  3. ajbozarth commented on Mar 6, 2026

    @ajbozarth
    Member

    Starting work on this on top of #563 for now, until #582 is merged and that PR can be refactored

  4. ajbozarth commented on Mar 7, 2026

    @ajbozarth
    Member

    I have this fully implemented on top of #563

    You can see the diff against that PR here: ajbozarth/mellea@feat/token-usage-metrics-v2...ajbozarth:mellea:feat/metrics-exporters#diff-1c3a2eaf649780ce41e49177748d524ac0e22b999d6ae64654a93869b4254912

    Once #563 is merged I will "rebase" that branch and open a PR

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

Metadata

Metadata

Assignees

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