Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net/http] add http.server.active_requests metric #4543

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hadrienk
Copy link

@hadrienk hadrienk commented Nov 10, 2023

Follow up of #2617. As @Aneurysm9 pointed out the Labeler can only be used after the next handler has been called. This means that for active requests it is impossible to inject attributes this way.

@hadrienk hadrienk requested review from Aneurysm9, dmathieu and a team as code owners November 10, 2023 07:13
Copy link

linux-foundation-easycla bot commented Nov 10, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@hadrienk
Copy link
Author

I suppose we could add a comment somewhere about the fact that only metrics recorded after the handler is called are modifiable using a Labeler.

@harsh-vipps
Copy link

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please

  1. Cover the new metric in tests.
  2. Add a changelog entry.

@pellared
Copy link
Member

Please resolve the conflicts. Otherwise I cannot even run the GitHub workflows.

@hadrienk
Copy link
Author

Tried hard to add the route tag to the active_request but since it has to be started before the tag is injected using the Labeler there's way to fix that without changing the API a lot.

Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Merging #4543 (42dc8bc) into main (5ba7d1e) will increase coverage by 0.0%.
Report is 1 commits behind head on main.
The diff coverage is 66.6%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #4543   +/-   ##
=====================================
  Coverage   80.8%   80.8%           
=====================================
  Files        150     150           
  Lines      10371   10361   -10     
=====================================
- Hits        8387    8380    -7     
+ Misses      1840    1835    -5     
- Partials     144     146    +2     
Files Coverage Δ
instrumentation/net/http/otelhttp/common.go 100.0% <ø> (ø)
instrumentation/net/http/otelhttp/handler.go 87.4% <84.2%> (-0.4%) ⬇️
...ion/google.golang.org/grpc/otelgrpc/interceptor.go 88.5% <47.0%> (+0.6%) ⬆️

@hadrienk
Copy link
Author

Anything else you need me to do on this PR?

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There is a vulnerability in the code
  2. The build fails

@@ -226,6 +244,10 @@ func (h *middleware) serveHTTP(w http.ResponseWriter, r *http.Request, next http
labeler := &Labeler{}
ctx = injectLabeler(ctx, labeler)

attrs := metric.WithAttributes(httpSchemeFromRequest(r), semconv.HTTPMethod(r.Method))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line would bring back the vulnerability caused by unbound cardinality metric attribute (HTTP method) GHSA-rcjv-mgp8-qvmr

@pellared
Copy link
Member

pellared commented Nov 16, 2023

Tried hard to add the route tag to the active_request but since it has to be started before the tag is injected using the Labeler there's way to fix that without changing the API a lot.

It is OK to not add it.

Take notice that this attribute is not specified in v1.20.0 (https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/metrics/semantic_conventions/http-metrics.md) nor in the latest (https://opentelemetry.io/docs/specs/semconv/http/http-metrics/#metric-httpserveractive_requests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants