-
Notifications
You must be signed in to change notification settings - Fork 3k
Add a way to access request context data in HttpServerMetricsTagsContributor
#47887
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
Conversation
|
/cc @brunobat (micrometer), @ebullient (micrometer) |
adutra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick implementation!
...er/runtime/src/main/java/io/quarkus/micrometer/runtime/HttpServerMetricsTagsContributor.java
Outdated
Show resolved
Hide resolved
cescoffier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of reading duplicated content after requests, but we can find a better way later.
|
Yeah, we will likely need a better solution in the future. The good thing with this, is that the use of DC is not exposed to the user |
This comment has been minimized.
This comment has been minimized.
``` - Refactor context local data handling across Micrometer integration to improve type safety with generics. - Simplify and clean up code by removing unnecessary type casts in `ContextLocalTag`. ```
|
@gastaldi actually now that I think of it we don't want that because it ties the type of the key and the type of value. |
No, they are totally unrelated. I can write |
|
👌 |
Status for workflow
|
| public class PathTemplateResource { | ||
| @GET | ||
| public String get(@PathParam("value") String value) { | ||
| ContextLocals.put("context-local", "val-" + value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad practice. We should not encourage ppl to add tags from path params. Even if they think the nr of different values are limited, they cannot really control it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be bad practice, but people shouldn't be limited by accidental technically reasons from doing it.
ThreadLocals should not be used generally, but that doesn't mean we should prevent their use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, but this should come with a big warning that they will shoot themselves in the foot if they don't consider cardinatility.
See for example: #users > Are you using path parameters? (metrics)
I think a warning should be placed in the docs and a in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because in the end, ppl will complain and we will spend time debugging this stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add we should also place a warning in the Javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to add something in the various places, I'll gladly approve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context: my initial use case is not related to path params, it's related to capturing the tenant ID associated with the request. And tenant IDs are guaranteed to form a finite set, although they could be like a thousand or so. Are you saying that even this use case is bad practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It must not be used like that.
It will blow the dimensions exponentially. Remember that for each tenant id you will have also different metrics per endpoint, response status and method.
Place that data in the span and later query the APM's span attributes and/or correlate with exemplars.
HttpServerMetricsTagsContributor#47886