Updates to new Observation classes
This commit is contained in:
@@ -29,7 +29,7 @@ public class CircuitBreakerObservationContext extends Observation.Context {
|
||||
private final Type type;
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link CircuitBreakerDocumentedObservation}.
|
||||
* Creates a new instance of {@link CircuitBreakerObservationDocumentation}.
|
||||
* @param type type of wrapped object
|
||||
*/
|
||||
public CircuitBreakerObservationContext(Type type) {
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.springframework.cloud.client.circuitbreaker.observation;
|
||||
import io.micrometer.common.docs.KeyName;
|
||||
import io.micrometer.observation.Observation;
|
||||
import io.micrometer.observation.ObservationConvention;
|
||||
import io.micrometer.observation.docs.DocumentedObservation;
|
||||
import io.micrometer.observation.docs.ObservationDocumentation;
|
||||
|
||||
enum CircuitBreakerDocumentedObservation implements DocumentedObservation {
|
||||
enum CircuitBreakerObservationDocumentation implements ObservationDocumentation {
|
||||
|
||||
/**
|
||||
* Observation created when we wrap a Supplier passed to the CircuitBreaker.
|
||||
@@ -76,7 +76,7 @@ enum CircuitBreakerDocumentedObservation implements DocumentedObservation {
|
||||
// }
|
||||
};
|
||||
|
||||
enum LowCardinalityTags implements KeyName {
|
||||
public enum LowCardinalityTags implements KeyName {
|
||||
|
||||
/**
|
||||
* Defines the type of wrapped lambda.
|
||||
@@ -28,11 +28,14 @@ import io.micrometer.common.KeyValues;
|
||||
*/
|
||||
public class DefaultCircuitBreakerObservationConvention implements CircuitBreakerObservationConvention {
|
||||
|
||||
static final DefaultCircuitBreakerObservationConvention INSTANCE = new DefaultCircuitBreakerObservationConvention();
|
||||
/**
|
||||
* Don't know why this needs to be public.
|
||||
*/
|
||||
public static final DefaultCircuitBreakerObservationConvention INSTANCE = new DefaultCircuitBreakerObservationConvention();
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(CircuitBreakerObservationContext context) {
|
||||
return KeyValues.of(CircuitBreakerDocumentedObservation.LowCardinalityTags.OBJECT_TYPE
|
||||
return KeyValues.of(CircuitBreakerObservationDocumentation.LowCardinalityTags.OBJECT_TYPE
|
||||
.withValue(context.getType().name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,9 @@ class ObservedFunction<T> implements Function<Throwable, T> {
|
||||
ObservedFunction(CircuitBreakerObservationConvention customConvention, CircuitBreakerObservationContext context,
|
||||
String conextualName, ObservationRegistry observationRegistry, Function<Throwable, T> toRun) {
|
||||
this.delegate = toRun;
|
||||
this.observation = CircuitBreakerDocumentedObservation.CIRCUIT_BREAKER_SUPPLIER_OBSERVATION.observation(
|
||||
customConvention, DefaultCircuitBreakerObservationConvention.INSTANCE, context, observationRegistry);
|
||||
this.observation = CircuitBreakerObservationDocumentation.CIRCUIT_BREAKER_SUPPLIER_OBSERVATION.observation(
|
||||
customConvention, DefaultCircuitBreakerObservationConvention.INSTANCE, () -> context,
|
||||
observationRegistry);
|
||||
this.observation.contextualName(conextualName);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,9 @@ class ObservedSupplier<T> implements Supplier<T> {
|
||||
ObservedSupplier(CircuitBreakerObservationConvention customConvention, CircuitBreakerObservationContext context,
|
||||
String contextualName, ObservationRegistry observationRegistry, Supplier<T> toRun) {
|
||||
this.delegate = toRun;
|
||||
this.observation = CircuitBreakerDocumentedObservation.CIRCUIT_BREAKER_SUPPLIER_OBSERVATION.observation(
|
||||
customConvention, DefaultCircuitBreakerObservationConvention.INSTANCE, context, observationRegistry);
|
||||
this.observation = CircuitBreakerObservationDocumentation.CIRCUIT_BREAKER_SUPPLIER_OBSERVATION.observation(
|
||||
customConvention, DefaultCircuitBreakerObservationConvention.INSTANCE, () -> context,
|
||||
observationRegistry);
|
||||
this.observation.contextualName(contextualName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user