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

[Flask] request_hook for metrics attributes

Open
#3,405 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?

We want to customize the attributes of metrics sent via FlaskInstrumentor#instrument_app, we did this with spans via request_hook and response_hook, but we didn't find a way to do that with metrics.

Describe the solution you'd like

There is a request_hook and response_hook in FlaskInstrumentor#instrument_app, however, the hook itself only works for traces, which is span specifically.

I'd like to see that the request_hook can also apply to metrics, for which we can provide more context via the hook function object.

Describe alternatives you've considered

No response

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 FlaskInstrumentor#instrument_app and compare how request_hook and response_hook are handled for traces with the metric instrumentation path. The change is complete when the request hook can provide additional context for customizing metrics attributes, with behavior covered by the relevant Flask instrumentation tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.