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

Introduce a way to provide custom micrometer metrics tags #34434

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Jun 30, 2023

Closes: #33313

@quarkus-bot
Copy link

quarkus-bot bot commented Jun 30, 2023

/cc @brunobat (micrometer), @ebullient (micrometer)


Tags configure(Context context);

interface Context {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for using this additional interface is that it allows us to introduce new items items to the API without breaking anything (as opposed to adding a new parameter to configure)

* <p>
* The implementations of this interface are meant to be registered via CDI beans.
*/
public interface AdditionalHttpServerMetricsTagsProvider {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I very much dislike this name, so if you have ideas, I'm all ears

Copy link
Contributor

Choose a reason for hiding this comment

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

it works for me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated it after talking to @ebullient

HttpCommonTags.status(response.statusCode()));
if (!additionalHttpServerMetricsTagsProviders.isEmpty()) {
AdditionalHttpServerMetricsTagsProvider.Context context = new DefaultContext(requestMetric.request());
for (int i = 0; i < additionalHttpServerMetricsTagsProviders.size(); i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for using foreach here is that I want to avoid creating garbage on this path

if (!additionalHttpServerMetricsTagsProviders.isEmpty()) {
AdditionalHttpServerMetricsTagsProvider.Context context = new DefaultContext(requestMetric.request());
for (int i = 0; i < additionalHttpServerMetricsTagsProviders.size(); i++) {
allTags = allTags.and(additionalHttpServerMetricsTagsProviders.get(i).configure(context));
Copy link
Contributor

Choose a reason for hiding this comment

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

What if configure throws a RuntimeException.. This was not the case until now, as tags were fix and resolved by Quarkus itself.. Propagate only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. @ebullient what's the best practice in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say skip adding the new tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍🏼

@ebullient
Copy link
Member

ebullient commented Jun 30, 2023

Given there is space between Vert.x and Quarkus here..

Can we have one interface for http tag contributors with default empty methods for hooking in server and client metrics? Just an idea, maybe it is bad. Could be discovered/anchored off of the HttpBinderConfig (which hosts both server things and client things), as http metrics are emitted in a few different places. Server side is straight-up. Client side is a PITA...

@geoand
Copy link
Contributor Author

geoand commented Jun 30, 2023

I'll have a look

@geoand
Copy link
Contributor Author

geoand commented Jul 3, 2023

I think it's would actually be kind of weird to have the same CDI bean for configuring client and server tags. I would personally prefer having two different interfaces.

@geoand geoand marked this pull request as ready for review July 3, 2023 06:37
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 3, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@ebullient ebullient merged commit aa990fe into quarkusio:main Jul 5, 2023
@quarkus-bot quarkus-bot bot added the kind/enhancement New feature or request label Jul 5, 2023
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 5, 2023
@geoand geoand deleted the #33313 branch July 12, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add posibility to have extra custom tags in HTTP metrics
4 participants