open-telemetry / open-telemetry/opentelemetry-python-contrib
Allow Flask instrumentation to filter on paths
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
The FlaskInstrumentor accepts an excluded_urls parameter, which takes a sequence of regular expressions that it compares against
flask.request.url, here:
In my opinion it would be nicer to be able to filter on the path instead (flask.request.path), at least in some cases.
For instance, if you want to disable tracing on the root path (so just /), that's relatively easy to do if you filter on path (with the regular expression^/$), but becomes a massive pain if you have to take the whole url into account.
It's probably too late to change the meaning of excluded_urls, but would it be possible to add an optional excluded_paths parameter?
If there's a chance that it would be accepted, I'd be happy to work on an implementation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/init.py at the excluded_urls handling around line 192. Trace how the existing URL filter is configured and applied, then determine how an optional excluded_paths filter should use flask.request.path while preserving excluded_urls behavior. Done means path-based filtering works for cases such as ^/$ and existing URL filtering remains compatible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100