Skip to content

Commit

Permalink
DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
evg-tso committed Sep 15, 2024
1 parent 10e71f2 commit 0e3a6b8
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/main/java/com/appsflyer/otelawsmetrics/OtelMetricPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public OtelMetricPublisher(OpenTelemetry openTelemetry, String metricPrefix) {
}

public OtelMetricPublisher(OpenTelemetry openTelemetry, String metricPrefix, Executor executor) {
this.metricPrefix = metricPrefix;
this.metricPrefix = metricPrefix + ".";
this.executor = executor;

Meter meter = openTelemetry.getMeter("aws.sdk");
Expand All @@ -71,76 +71,76 @@ public void close() {

private Map<String, MetricStrategy> initializePerRequestStrategies(Meter meter) {
return Map.of(CoreMetric.API_CALL_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".api_call_duration",
metricPrefix + "api_call_duration",
"The total time taken to finish a request (inclusive of all retries)")),

CoreMetric.CREDENTIALS_FETCH_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".credentials_fetch_duration",
metricPrefix + "credentials_fetch_duration",
"The time taken to fetch AWS signing credentials for the request")),

CoreMetric.ENDPOINT_RESOLVE_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".endpoint_resolve_duration",
metricPrefix + "endpoint_resolve_duration",
"The duration of time it took to resolve the endpoint used for the API call")),

CoreMetric.MARSHALLING_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".marshalling_duration",
metricPrefix + "marshalling_duration",
"The time it takes to marshall an SDK request to an HTTP request")),

CoreMetric.TOKEN_FETCH_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".token_fetch_duration",
metricPrefix + "token_fetch_duration",
"The time taken to fetch token signing credentials for the request")));
}

private Map<String, MetricStrategy> initializeCoreStrategies(Meter meter) {

return Map.of(CoreMetric.BACKOFF_DELAY_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".backoff_delay_duration",
metricPrefix + "backoff_delay_duration",
"The duration of time the SDK waited before this API call attempt")),

CoreMetric.READ_THROUGHPUT.name(), new MetricStrategyWithoutErrors(new DoubleHistogramStrategy(meter,
metricPrefix + ".read_throughput",
metricPrefix + "read_throughput",
"The read throughput of the client in bytes/second")),

CoreMetric.SERVICE_CALL_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".service_call_duration",
metricPrefix + "service_call_duration",
"The time it takes to connect to the service, send the request, and receive the HTTP status code and header from the response")),

CoreMetric.SIGNING_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".signing_duration",
metricPrefix + "signing_duration",
"The time it takes to sign the HTTP request")),

CoreMetric.TIME_TO_FIRST_BYTE.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".time_to_first_byte",
metricPrefix + "time_to_first_byte",
"Elapsed time from sending the HTTP request (including acquiring a connection) to receiving the first byte of the headers in the response")),

CoreMetric.TIME_TO_LAST_BYTE.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".time_to_last_byte",
metricPrefix + "time_to_last_byte",
"Elapsed time from sending the HTTP request (including acquiring a connection) to receiving the last byte of the response")),

CoreMetric.UNMARSHALLING_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".unmarshalling_duration",
metricPrefix + "unmarshalling_duration",
"The time it takes to unmarshall an HTTP response to an SDK response")));
}

private Map<String, MetricStrategy> initializeHttpStrategies(Meter meter) {
return Map.of(HttpMetric.AVAILABLE_CONCURRENCY.name(), new MetricStrategyWithoutErrors(new LongHistogramStrategy(meter,
metricPrefix + ".available_concurrency",
metricPrefix + "available_concurrency",
"The number of remaining concurrent requests that can be supported by the HTTP client without needing to establish another connection")),

HttpMetric.CONCURRENCY_ACQUIRE_DURATION.name(), new MetricStrategyWithoutErrors(new DurationStrategy(meter,
metricPrefix + ".concurrency_acquire_duration",
metricPrefix + "concurrency_acquire_duration",
"The time taken to acquire a channel from the connection pool")),

HttpMetric.LEASED_CONCURRENCY.name(), new MetricStrategyWithoutErrors(new LongHistogramStrategy(meter,
metricPrefix + ".leased_concurrency",
metricPrefix + "leased_concurrency",
"The number of request currently being executed by the HTTP client")),

HttpMetric.MAX_CONCURRENCY.name(), new MetricStrategyWithoutErrors(new LongHistogramStrategy(meter,
metricPrefix + ".max_concurrency",
metricPrefix + "max_concurrency",
"The max number of concurrent requests supported by the HTTP client")),

HttpMetric.PENDING_CONCURRENCY_ACQUIRES.name(), new MetricStrategyWithoutErrors(new LongHistogramStrategy(meter,
metricPrefix + ".pending_concurrency_acquires",
metricPrefix + "pending_concurrency_acquires",
"The number of requests that are blocked, waiting for another TCP connection or a new stream to be available from the connection pool")));
}

Expand Down

0 comments on commit 0e3a6b8

Please sign in to comment.