-
Notifications
You must be signed in to change notification settings - Fork 979
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
Allow multiple MeterTag annotations for multiple tags from same target #4081
Comments
Maybe I'm missing sth, can you provide an example of what doesn't work currently? |
hey @marcingrzejszczak, thanks for taking a look. Suppose we have the following code: public ChargeResponse chargeInstrument(ChargeInstrumentRequest chargeInstrumentRequest) {
}
public class ChargeInstrumentRequest {
String currency; // EUR, USD etc
String instrumentType; // CARD, PAYPAL etc
} I can use @MeterTag to extract 1 field: @MeterTag(key = "instrument_type", expression = "instrumentType") If I also want to use the currency as a tag, I don't see a way to do it with @MeterTag, I cannot repeat @MeterTag and @MeterTag does not accept a list of keyvaluepairs, I could implement my custom extractor, but would be nice to use spel with @MeterTag. I am still on spring boot 2.x, planning to upgrade soon, my apologies if this was solved in 3.x, but from the micrometer documentation, it seemed like this is still going to be a problem in 3.x |
Do I understand correctly that you would like to use a single method parameter as 2 tags? In other words annotate the currency parameter twice with different values? |
Correct, I'd like to do public ChargeResponse chargeInstrument(@MeterTag(key = "instrument_type", expression = "instrumentType") @MeterTag(key = "currency", expression = "currency") ChargeInstrumentRequest chargeInstrumentRequest) {
} Or if the annotation cannot be repeated(it is just an example). Providing a key-value pair is probably more readable, where the key is the metric key and the value is the spel that resolves the value from the input parameter. |
it seems that the only missing thing is the declaration of
|
Care for a PR? |
Sure #5055 |
Unfortunately, I had to revert this change as it broke the build and we need to get 1.14.0-M1 released. See #5055 (comment) |
Please see the new one: #5292 |
Please describe the feature request.
The '@MeterTag' feature lets you add dynamic tags, taking a value from a parameter. Currently, you can only extract one key/value pair because annotation can't be repeated and I did not see a way to define a list of key/value pairs.
It would be helpful to allow for extracting multiple key-value pairs.
Rationale
For APIs with numerous fields, it would be beneficial to create multiple tags for improved filtering.
Additional context
The text was updated successfully, but these errors were encountered: