Fix ClassCastException in ObservationRequestTracker.
This fixes a ClassCastException for CassandraObservationContext when a NoopObservation is returned by the observation registry. Closes #1541
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
package org.springframework.data.cassandra.observability;
|
package org.springframework.data.cassandra.observability;
|
||||||
|
|
||||||
import io.micrometer.observation.Observation;
|
import io.micrometer.observation.Observation;
|
||||||
|
import io.micrometer.observation.Observation.Context;
|
||||||
import io.micrometer.observation.Observation.Event;
|
import io.micrometer.observation.Observation.Event;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -85,15 +86,19 @@ public enum ObservationRequestTracker implements RequestTracker {
|
|||||||
if (request instanceof CassandraObservationSupplier) {
|
if (request instanceof CassandraObservationSupplier) {
|
||||||
|
|
||||||
Observation observation = ((CassandraObservationSupplier) request).getObservation();
|
Observation observation = ((CassandraObservationSupplier) request).getObservation();
|
||||||
|
Context context = observation.getContext();
|
||||||
|
|
||||||
((CassandraObservationContext) observation.getContext()).setNode(node);
|
if (context instanceof CassandraObservationContext) {
|
||||||
|
|
||||||
observation.highCardinalityKeyValue(
|
((CassandraObservationContext) context).setNode(node);
|
||||||
String.format(HighCardinalityKeyNames.NODE_ERROR_TAG.asString(), node.getEndPoint()), error.toString());
|
|
||||||
observation.event(Event.of(Events.NODE_ERROR.getValue()));
|
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
observation.highCardinalityKeyValue(
|
||||||
log.debug("Marking node error for [" + observation + "]");
|
String.format(HighCardinalityKeyNames.NODE_ERROR_TAG.asString(), node.getEndPoint()), error.toString());
|
||||||
|
observation.event(Event.of(Events.NODE_ERROR.getValue()));
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Marking node error for [" + observation + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,13 +110,17 @@ public enum ObservationRequestTracker implements RequestTracker {
|
|||||||
if (request instanceof CassandraObservationSupplier) {
|
if (request instanceof CassandraObservationSupplier) {
|
||||||
|
|
||||||
Observation observation = ((CassandraObservationSupplier) request).getObservation();
|
Observation observation = ((CassandraObservationSupplier) request).getObservation();
|
||||||
|
Context context = observation.getContext();
|
||||||
|
|
||||||
((CassandraObservationContext) observation.getContext()).setNode(node);
|
if (context instanceof CassandraObservationContext) {
|
||||||
|
|
||||||
observation.event(Event.of(Events.NODE_SUCCESS.getValue()));
|
((CassandraObservationContext) context).setNode(node);
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
observation.event(Event.of(Events.NODE_SUCCESS.getValue()));
|
||||||
log.debug("Marking node success for [" + observation + "]");
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Marking node success for [" + observation + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user