-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Please describe the feature request.
I would like to be able to put values into baggage scope for the duration of a method using annotations. I would like to be able to use static values, or values from the method arguments.
Rationale
In my Spring Boot application I have several controllers. For each controller, I want to put some values from the method arguments into baggage. I currently do that by wrapping the whole controller like this:
void doSomething(String value1) {
try (BaggageInScope scope = this.tracer.createBaggageInScope("customer.id", "value1")) {
// Business logic
}
}
This approach pollutes my business logic, as every controller is in a try block related to tracing. It would be good if I could so something like:
@Observed
void doSomething(@BaggageInScope((key = "customer.id") String value1) {
// Business logic
}
Additional context
I've had a look at @ObservationKeyValue which was added under this ticket micrometer-metrics/micrometer#4030. This seems related to this request, but I don't think @ObservationKeyValue puts anything into Baggage scope.
In my Spring Boot application I have written an Aspect to do pretty much the same thing as described above using a custom annotation. It works well. I was thinking something similar would be a good feature in Micrometer generally?