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

Add extra-labels to Ring collector #4

Closed

Conversation

psalaberria002
Copy link
Contributor

Currently the default labels are [:method :status :statusClass :path].

I would like to have the ability to add extra labels from the request or response.

If this is not the right approach, do you have any other ideas for how to solve it?

Thank you.

@xsc
Copy link
Collaborator

xsc commented Mar 30, 2017

@psalaberria002 Thanks for addressing this!

I think there might be a cleaner, more Ring-like way of doing this, namely by using a well known field (e.g. :iapetos/labels) in the request or response map. Then, request labels could be added by middlewares on top, while response labels could be added by middlewares below (or the handler itself). What do you think?

@xsc xsc requested review from xsc and removed request for xsc March 30, 2017 13:35
@xsc xsc self-assigned this Mar 30, 2017
@psalaberria002
Copy link
Contributor Author

Is this closer to what you were suggesting? It gets labels (specific ns kw) from both the request and the response.

I still don't like the need to define labels when calling ring/initialize. Do you know if this can be done on the fly by some middleware?

@xsc
Copy link
Collaborator

xsc commented Mar 31, 2017

@psalaberria002 I don't think you can add labels on-demand since collectors (and thus their labels) have to be registered before they are ever used. I don't see a way of dynamically adding/removing labels in the code or the docs.

As to your implementation: Looking good! Only thing I'm uncertain about is whether :iapetos.collector.ring/labels is maybe a bit verbose/inconvenient to use, so maybe something like :iapetos/labels or a plain :metric-labels might be preferable.

@psalaberria002
Copy link
Contributor Author

I just wanted to be specific, since these labels are only relevant for ring metrics. Why is :iapetos/labels a better kw? Won't this be confusing? Give me a good reason and I change it ;)

@xsc
Copy link
Collaborator

xsc commented Mar 31, 2017

@psalaberria002 Since it's a key within a Ring request or response map I think the "only relevant for ring metrics" part is given by context. Also, :iapetos/labels and :metric-labels are arguably more stable/reusable than tying the key to a specific namespace.

But, maybe the fact that we're arguing about this shows that it's not the correct approach. How do you feel about having an additional :label-fn option instead that takes request and response as parameters and computes the additional metric labels? Cleans up the code a bit and is more flexible than our current approach.

@psalaberria002
Copy link
Contributor Author

Great idea! Leaving the implementation up to the user sounds more flexible. Will try to have a patch during the day. Thank you for the fast replies.

@psalaberria002
Copy link
Contributor Author

Any updates on this one?

@xsc
Copy link
Collaborator

xsc commented Apr 6, 2017

I removed the default-label-fn and added a dedicated test case. Committed to master in f8d1fa2.

@xsc xsc closed this Apr 6, 2017
@xsc
Copy link
Collaborator

xsc commented Apr 6, 2017

Release Notes

@psalaberria002
Copy link
Contributor Author

Great! Thank you.

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.

2 participants