Class OpenTelemetryResponseSerializer

java.lang.Object
com.commercetools.monitoring.opentelemetry.OpenTelemetryResponseSerializer
All Implemented Interfaces:
ResponseSerializer

public class OpenTelemetryResponseSerializer extends Object implements 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.