inspectit-ocelot
inspectit-ocelot copied to clipboard
[Feature] - *Enable Lambda expressions in actions*
Is your feature request related to a problem? Please describe. Currently, it is not possible to use Java code snippets, which contain lambda expressions for actions. This is probably the fault of Javassist, which is responsible to compile the code snippets. Since more and more libraries we want to instrument use asynchronous approaches, we need to be able to work with lambdas.
Describe the solution you'd like Check, if Javassist is capable of using lambdas in code snippets. Maybe we would have to look for another library.
Additional context I discoverd the OpenTelemetry Java agent sometimes uses the decorator pattern, to add instrumentation logic to callback functions. For example here: DecoratorFunctions.
It would be awesome, if we could use actions like this:
a_decorate:
is-void: true
input:
_arg0: java.util.function.BiConsumer
_context: InspectitContext
value-body: |
BiConsumer callback = _arg0;
BiConsumer wrapper = (k,v) -> {
// insert instrumentation logic
String key = (String) k;
_context.setData("my-key", key);
// call original function
callback.accept(k,v);
};
_arg0 = wrapper;