Skip to content

feat(otel): add configurable otel_path option for OTEL metrics exporter - #77340

Open
pavankumargp6 wants to merge 5 commits into
apache:mainfrom
pavankumargp6:fix-otel-metrics-path-config
Open

pavankumargp6 wants to merge 5 commits into
apache:mainfrom
pavankumargp6:fix-otel-metrics-path-config

Conversation

@pavankumargp6

Copy link
Copy Markdown

Closes #42492

Currently the OTEL metrics exporter hardcodes /v1/metrics as the endpoint path. Some collectors like VictoriaMetrics expect metrics at different paths (e.g. /opentelemetry/api/v1/push or /insert/0/).

Changes

  1. shared/observability/src/airflow_shared/observability/common.py

    • Added path: str | None = None parameter to get_otel_data_exporter()
    • When constructing the endpoint URL, uses path if provided, falling back to /v1/{endpoint_suffix}
  2. shared/observability/src/airflow_shared/observability/metrics/otel_logger.py

    • Added path: str | None = None parameter to get_otel_logger()
    • Passes path through to get_otel_data_exporter()
  3. airflow-core/src/airflow/observability/metrics/otel_logger.py

    • Reads [metrics] otel_path config with fallback to /v1/metrics
    • Passes it through to the shared get_otel_logger()
  4. task-sdk/src/airflow/sdk/observability/metrics/otel_logger.py

    • Same config read and pass-through as the airflow-core wrapper
  5. airflow-core/src/airflow/config_templates/config.yml

    • Added otel_path config option in the [metrics] section with default /v1/metrics

Usage

Set in airflow.cfg:

[metrics]
otel_path = /opentelemetry/api/v1/push

Or via environment variable (standard OTel):

OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://collector:4318/opentelemetry/api/v1/push

@boring-cyborg

boring-cyborg Bot commented Nov 19, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@pavankumargp6

Copy link
Copy Markdown
Author

Hi maintainers, before adding tests and a newsfragment I'd like to confirm the design for otel_path: should it be a path-only value (e.g., /v1/metrics) that gets appended to the configured otel_endpoint, or a full endpoint override (e.g., https://collector:4318/v1/metrics)? The current implementation treats it as a path appended to otel_endpoint, but the config description says "path to the OTLP endpoint" which could be interpreted either way. Please confirm the intended semantics so I can add correct tests, docs, and a newsfragment.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide configuration option to configure path of OTEL metrics exporter

1 participant