Add test for OpenTelemetryServerRequestObservationConvention

See gh-35358
This commit is contained in:
Tommy Ludwig
2025-08-20 16:16:23 +02:00
committed by Brian Clozel
parent 3269751887
commit 7e45f609a2
3 changed files with 164 additions and 5 deletions
@@ -97,7 +97,7 @@ public enum OpenTelemetryServerHttpObservationDocumentation implements Observati
},
/**
* Name of the exception thrown during the exchange, or
* Fully qualified name of the exception thrown during the exchange, or
* {@value KeyValue#NONE_VALUE} if no exception was thrown.
*/
EXCEPTION {
@@ -29,7 +29,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.server.observation.OpenTelemetryServerHttpObservationDocumentation.HighCardinalityKeyNames;
import org.springframework.http.server.observation.OpenTelemetryServerHttpObservationDocumentation.LowCardinalityKeyNames;
import org.springframework.util.StringUtils;
/**
* A {@link ServerRequestObservationConvention} based on the stable OpenTelemetry semantic conventions.
@@ -180,9 +179,7 @@ public class OpenTelemetryServerRequestObservationConvention implements ServerRe
protected KeyValue exception(ServerRequestObservationContext context) {
Throwable error = context.getError();
if (error != null) {
String simpleName = error.getClass().getSimpleName();
return KeyValue.of(LowCardinalityKeyNames.EXCEPTION,
StringUtils.hasText(simpleName) ? simpleName : error.getClass().getName());
return KeyValue.of(LowCardinalityKeyNames.EXCEPTION, error.getClass().getName());
}
return EXCEPTION_NONE;
}