Skip to content

Commit

Permalink
Make javadoc consistent across monitoring middlewares (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
lojzatran authored Apr 8, 2024
1 parent 311730d commit 5009ae8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
import io.vrap.rmf.base.client.ApiHttpResponse;
import io.vrap.rmf.base.client.http.TelemetryMiddleware;

/**
* <p>The DatadogTelemetry middleware can be used to report outgoing request to commercetools to Datadog.
* It can be registered as TelemetryMiddleware to the {@link io.vrap.rmf.base.client.ClientBuilder#withTelemetryMiddleware(TelemetryMiddleware) ClientBuilder}
* or the ApiRootBuilder.</p>
*
* {@include.example example.DatadogApiRootBuilderTest#addDatadogTelemetry()}
*
* The middleware adds the following metrics to Datadog:
* <ul>
* <li>commercetools.client.duration: The duration of the request in milliseconds</li>
* <li>commercetools.client.total_requests: The total number of requests</li>
* <li>commercetools.client.error_requests: The total number of requests with a status code greater or equal to 400</li>
* </ul>
*
* <p>The metrics are enriched with the response status code, server address, port and request method.</p>
*
* <p>See also the <a href="https://github.com/commercetools/commercetools-sdk-java-v2/tree/main/examples/spring-datadog">Spring MVC example application</a> in the examples folder for further details.</p>
*/
public class DatadogMiddleware implements TelemetryMiddleware {

private final MetricsApi apiInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class DatadogApiRootBuilderTest {

public void addOpenTelemetry() {
public void addDatadogTelemetry() {
ApiHttpClient client = ApiRootBuilder.of()
.defaultClient(ServiceRegion.GCP_EUROPE_WEST1.getApiUrl())
.withTelemetryMiddleware(new DatadogMiddleware(ApiClient.getDefaultApiClient()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@
*
* {@include.example example.OpenTelemetryApiRootBuilderTest#addOpenTelemetry()}
*
* <p>The middleware records a histogram about the request timing in milliseconds. The total number of responses and errors is counted.
* The middleware adds the following metrics:
* * <ul>
* <li>commercetools.client.duration: The duration of the request in milliseconds</li>
* <li>commercetools.client.total_requests: The total number of requests</li>
* <li>commercetools.client.error_requests: The total number of requests with a status code greater or equal to 400</li>
* * </ul>
*
* The metrics are enriched with the response status code, server address, port and request method.</p>
*
* <p>See also the <a href="https://github.com/commercetools/commercetools-sdk-java-v2/tree/main/examples/spring-otel">Spring MVC example application</a> in the examples folder for further details.</p>
*/
public class OpenTelemetryMiddleware implements TelemetryMiddleware {
private final LongHistogram histogram;
Expand Down
8 changes: 8 additions & 0 deletions src/main/javadoc/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ <h2>Monitoring</h2>
{@link com.commercetools.monitoring.newrelic.NewRelicTelemetryMiddleware NewRelic}
{@include.toc com.commercetools.monitoring.newrelic.NewRelicTelemetryMiddleware}
</li>
<li>
{@link com.commercetools.monitoring.datadog.DatadogMiddleware Datadog}
{@include.toc com.commercetools.monitoring.datadog.DatadogMiddleware}
</li>
<li>
{@link com.commercetools.monitoring.opentelemetry.OpenTelemetryMiddleware OpenTelemetryMiddleware}
{@include.toc com.commercetools.monitoring.opentelemetry.OpenTelemetryMiddleware}
</li>
</ol>
</div>
</body>

0 comments on commit 5009ae8

Please sign in to comment.