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

Allow Flask instrumentation to filter on paths

Open
#1,181 8 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

The FlaskInstrumentor accepts an excluded_urls parameter, which takes a sequence of regular expressions that it compares against

flask.request.url, here:

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py#L192

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.