Description
tomliliu opened SPR-5859 and commented
Hi,
I'd like to understand why @ManagedOperation
can not be used on getter.
I want some expensive metrics not exposed as attribute but retrieved by explicitly invoking the getter operation.
Ideally, I'd like to put @ManagedOperation
on top of the getter method to do that.
Here is a use case:
@ManagedResource
public class Resource {
@ManagedOperation
public ExpensiveMetric getExpensiveMetric() {
//collecting the expensive metrics
....
return ...;
}
}
Because the computation is expensive, we want to avoid unnecessary computations. If we expose it as ManagedAttribute then a lot of unnecessary compuations will happen because visualvm will retrieve all attribute values even if the user is not interested in the expensive metrics at that moment. So that's the reason why we want to expose getExpensiveMetric as operation instead of attribute. And also, I am reluctant to change api only for the sake of exposing it as operation.
Thanks,
Tom
Affects: 2.5.6
Issue Links:
- Spring Reference Documentation is missing documentation of restrictions of ManagedAttribute and ManagedOperation [SPR-6026] #10695 Spring Reference Documentation is missing documentation of restrictions of ManagedAttribute and ManagedOperation ("is depended on by")
Referenced from: commits aa08c11