open-telemetry / open-telemetry/opentelemetry-python-contrib

Starlette Instrumentation: Allow to pass excluded_urls in the middleware constructor

Open
#2,863 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

What problem do you want to solve?

I want exclude health probe endpoints in my framework (e.g. they are at the same URL in all microservices) that are used by a few dozens of microservices.

Describe the solution you'd like

I would like to pass a list of well-known URL to exclude seamlessly for all microservices. That's not really possible without hacks as the middleware constructor doesn't expose a relevant configuration in:

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py#L202-L210

Describe alternatives you've considered

I could use environment variables like OTEL_PYTHON_STARLETTE_EXCLUDED_URLS or OTEL_PYTHON_EXCLUDED_URLS, but it would mean:

  • adding that env var to a few dozens of microservice charts
  • potentially exposing this unneeded information to chart users (that might be outside of the team or even organization)

So it would be so much better to keep this knowledge as part of the framework.

Additional Context

No response

Would you like to implement a fix?

None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Starlette middleware constructor in instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/init.py, around lines 202-210, and trace how its configuration reaches request instrumentation. Done means callers can provide excluded URLs there so shared health-probe endpoints are omitted without environment variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.