Class OpenTelemetryResponseSerializer
java.lang.Object
com.commercetools.monitoring.opentelemetry.OpenTelemetryResponseSerializer
- All Implemented Interfaces:
ResponseSerializer
The OpenTelemetry ResponseSerializer can be used to report metrics about the De-/Serialization performance.
It can be registered as a ResponseSerializer
to the ClientBuilder.withSerializer(ResponseSerializer)
ClientBuilder
or the ApiRootBuilder.
ApiHttpClient client = ApiRootBuilder.of() .defaultClient(ServiceRegion.GCP_EUROPE_WEST1.getApiUrl()) .withSerializer(new OpenTelemetryResponseSerializer(ResponseSerializer.of(), GlobalOpenTelemetry.get())) .buildClient();
See the test code.
The response serializer records a histogram about the serialization and deserialization timing of JSON in milliseconds. The metrics are enriched with the de-/serialized class name.
-
Constructor Summary
ConstructorDescriptionOpenTelemetryResponseSerializer
(ResponseSerializer serializer, io.opentelemetry.api.OpenTelemetry otel) OpenTelemetryResponseSerializer
(ResponseSerializer serializer, io.opentelemetry.api.OpenTelemetry otel, String prefix) -
Method Summary
Modifier and TypeMethodDescription<O> ApiHttpResponse<O>
convertResponse
(ApiHttpResponse<byte[]> response, com.fasterxml.jackson.core.type.TypeReference<O> outputType) <O> ApiHttpResponse<O>
convertResponse
(ApiHttpResponse<byte[]> response, JavaType outputType) <O> ApiHttpResponse<O>
convertResponse
(ApiHttpResponse<byte[]> response, Class<O> outputType) byte[]
toJsonByteArray
(Object value)
-
Constructor Details
-
OpenTelemetryResponseSerializer
public OpenTelemetryResponseSerializer(ResponseSerializer serializer, io.opentelemetry.api.OpenTelemetry otel) -
OpenTelemetryResponseSerializer
public OpenTelemetryResponseSerializer(ResponseSerializer serializer, io.opentelemetry.api.OpenTelemetry otel, String prefix)
-
-
Method Details
-
convertResponse
public <O> ApiHttpResponse<O> convertResponse(ApiHttpResponse<byte[]> response, Class<O> outputType) - Specified by:
convertResponse
in interfaceResponseSerializer
-
convertResponse
public <O> ApiHttpResponse<O> convertResponse(ApiHttpResponse<byte[]> response, JavaType outputType) - Specified by:
convertResponse
in interfaceResponseSerializer
-
convertResponse
public <O> ApiHttpResponse<O> convertResponse(ApiHttpResponse<byte[]> response, com.fasterxml.jackson.core.type.TypeReference<O> outputType) - Specified by:
convertResponse
in interfaceResponseSerializer
-
toJsonByteArray
public byte[] toJsonByteArray(Object value) throws com.fasterxml.jackson.core.JsonProcessingException - Specified by:
toJsonByteArray
in interfaceResponseSerializer
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-