Class DatadogMiddleware

All Implemented Interfaces:
Middleware, TelemetryMiddleware

public class DatadogMiddleware extends Object implements TelemetryMiddleware

The DatadogTelemetry middleware can be used to report outgoing request to commercetools to Datadog. This middleware uses Datadog API to submit telemetry data. It can be registered as TelemetryMiddleware to the ClientBuilder or the ApiRootBuilder.

ApiHttpClient client = ApiRootBuilder.of()
        .withTelemetryMiddleware(new DatadogMiddleware(new NonBlockingStatsDClientBuilder().build()))

See the test code.

The middleware adds the following metrics to Datadog:
  • 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

The metrics are enriched with the response status code, server address, port and request method.

See also the Spring MVC example application in the examples folder for further details.