Class OpenTelemetryMiddleware
java.lang.Object
com.commercetools.monitoring.opentelemetry.OpenTelemetryMiddleware
- All Implemented Interfaces:
Middleware
,TelemetryMiddleware
The OpenTelemetry middleware can be used to report metrics about outgoing request to commercetools.
It can be registered as TelemetryMiddleware to the ClientBuilder
or the ApiRootBuilder.
ApiHttpClient client = ApiRootBuilder.of() .defaultClient(ServiceRegion.GCP_EUROPE_WEST1.getApiUrl()) .withTelemetryMiddleware(new OpenTelemetryMiddleware(GlobalOpenTelemetry.get())) .buildClient();
See the test code.
- commercetools.client.duration: The duration of the request in milliseconds
- commercetools.client.total_requests: The total number of requests
- commercetools.client.error_requests: The total number of requests with a status code greater or equal to 400 *
See also the Spring MVC example application in the examples folder for further details.
-
Constructor Summary
ConstructorDescriptionOpenTelemetryMiddleware
(io.opentelemetry.api.OpenTelemetry otel) OpenTelemetryMiddleware
(io.opentelemetry.api.OpenTelemetry otel, boolean enableHistogram) OpenTelemetryMiddleware
(io.opentelemetry.api.OpenTelemetry otel, boolean enableHistogram, String prefix) -
Method Summary
Modifier and TypeMethodDescriptionCompletableFuture<ApiHttpResponse<byte[]>>
invoke
(ApiHttpRequest request, Function<ApiHttpRequest, CompletableFuture<ApiHttpResponse<byte[]>>> next)
-
Constructor Details
-
OpenTelemetryMiddleware
public OpenTelemetryMiddleware(io.opentelemetry.api.OpenTelemetry otel) -
OpenTelemetryMiddleware
public OpenTelemetryMiddleware(io.opentelemetry.api.OpenTelemetry otel, boolean enableHistogram) -
OpenTelemetryMiddleware
public OpenTelemetryMiddleware(io.opentelemetry.api.OpenTelemetry otel, boolean enableHistogram, String prefix)
-
-
Method Details
-
invoke
public CompletableFuture<ApiHttpResponse<byte[]>> invoke(ApiHttpRequest request, Function<ApiHttpRequest, CompletableFuture<ApiHttpResponse<byte[]>>> next) - Specified by:
invoke
in interfaceMiddleware
-