Browse Source

Updates to new Observation classes

tls-versions
spencergibb 2 years ago
parent
commit
c0c2b1ee83
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 2
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/CircuitBreakerObservationContext.java
  2. 6
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/CircuitBreakerObservationDocumentation.java
  3. 7
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/DefaultCircuitBreakerObservationConvention.java
  4. 5
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/ObservedFunction.java
  5. 5
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/ObservedSupplier.java

2
spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/CircuitBreakerObservationContext.java

@ -29,7 +29,7 @@ public class CircuitBreakerObservationContext extends Observation.Context { @@ -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) {

6
spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/CircuitBreakerDocumentedObservation.java → spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/CircuitBreakerObservationDocumentation.java

@ -19,9 +19,9 @@ package org.springframework.cloud.client.circuitbreaker.observation; @@ -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 { @@ -76,7 +76,7 @@ enum CircuitBreakerDocumentedObservation implements DocumentedObservation {
// }
};
enum LowCardinalityTags implements KeyName {
public enum LowCardinalityTags implements KeyName {
/**
* Defines the type of wrapped lambda.

7
spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/DefaultCircuitBreakerObservationConvention.java

@ -28,11 +28,14 @@ import io.micrometer.common.KeyValues; @@ -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)));
}

5
spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/ObservedFunction.java

@ -37,8 +37,9 @@ class ObservedFunction<T> implements Function<Throwable, T> { @@ -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);
}

5
spring-cloud-commons/src/main/java/org/springframework/cloud/client/circuitbreaker/observation/ObservedSupplier.java

@ -37,8 +37,9 @@ class ObservedSupplier<T> implements Supplier<T> { @@ -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);
}

Loading…
Cancel
Save