Adjust code and POM to accomodate for micrometer/observability changes

This commit is contained in:
Oleg Zhurakousky
2022-10-11 16:08:45 +02:00
parent 7a280f9399
commit 4a58eb75ef
3 changed files with 12 additions and 4 deletions

View File

@@ -17,14 +17,14 @@
package org.springframework.cloud.function.observability;
import io.micrometer.common.docs.KeyName;
import io.micrometer.observation.docs.DocumentedObservation;
import io.micrometer.observation.docs.ObservationDocumentation;
/**
* @author Marcin Grzejszczak
* @author Oleg Zhurakousky
* @since 4.0.0
*/
enum FunctionObservation implements DocumentedObservation {
enum FunctionObservation implements ObservationDocumentation {
/**
* Observation created around a function execution.
*/

View File

@@ -66,7 +66,7 @@ public class ObservationFunctionAroundWrapper extends FunctionAroundWrapper {
FunctionContext context = new FunctionContext(targetFunction).withInput(message);
Object invocationMessage = context.getModifiedInput();
Object result = Observation
.createNotStarted(FunctionObservation.FUNCTION_OBSERVATION.getName(), context, this.observationRegistry)
.createNotStarted(FunctionObservation.FUNCTION_OBSERVATION.getName(), () -> context, this.observationRegistry)
.contextualName(FunctionObservation.FUNCTION_OBSERVATION.getContextualName())
.observe(() -> {
Object r = message == null ? targetFunction.get() : targetFunction.apply(invocationMessage);