Skip to content

Commit 22b0fa9

Browse files
committed
Applied Spotless to ensure code formatting compliance
1 parent af55b75 commit 22b0fa9

File tree

8 files changed

+292
-152
lines changed

8 files changed

+292
-152
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.instrumentation.awssdk.v2_2.internal;
27

38
import io.opentelemetry.api.common.Attributes;
49
import io.opentelemetry.api.metrics.DoubleHistogram;
510
import io.opentelemetry.api.metrics.Meter;
6-
import software.amazon.awssdk.metrics.MetricRecord;
711
import java.util.logging.Level;
812
import java.util.logging.Logger;
13+
import software.amazon.awssdk.metrics.MetricRecord;
914

1015
/**
1116
* Records double value metrics using a DoubleHistogram.
12-
* <p>
13-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
17+
*
18+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
19+
* at any time.
1420
*/
1521
public class DoubleHistogramStrategy implements MetricStrategy {
1622
private static final Logger logger = Logger.getLogger(DoubleHistogramStrategy.class.getName());
1723
private final DoubleHistogram histogram;
1824

1925
public DoubleHistogramStrategy(Meter meter, String metricName, String description) {
20-
this.histogram = meter.histogramBuilder(metricName)
21-
.setDescription(description)
22-
.build();
26+
this.histogram = meter.histogramBuilder(metricName).setDescription(description).build();
2327
}
2428

2529
@Override
@@ -29,7 +33,9 @@ public void record(MetricRecord<?> metricRecord, Attributes attributes) {
2933
histogram.record(value, attributes);
3034
} else {
3135
logger.log(
32-
Level.WARNING,"Invalid value type for a DoubleHistogram metric: {}", metricRecord.metric().name());
36+
Level.WARNING,
37+
"Invalid value type for a DoubleHistogram metric: {}",
38+
metricRecord.metric().name());
3339
}
3440
}
3541
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.instrumentation.awssdk.v2_2.internal;
27

38
import io.opentelemetry.api.common.Attributes;
49
import io.opentelemetry.api.metrics.LongHistogram;
510
import io.opentelemetry.api.metrics.Meter;
6-
import software.amazon.awssdk.metrics.MetricRecord;
7-
811
import java.time.Duration;
912
import java.util.logging.Level;
1013
import java.util.logging.Logger;
14+
import software.amazon.awssdk.metrics.MetricRecord;
1115

1216
/**
1317
* Records duration metrics using a LongHistogram.
14-
* <p>
15-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
18+
*
19+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
20+
* at any time.
1621
*/
1722
public class DurationStrategy implements MetricStrategy {
1823
private static final Logger logger = Logger.getLogger(DurationStrategy.class.getName());
1924
private final LongHistogram histogram;
2025

2126
public DurationStrategy(Meter meter, String metricName, String description) {
22-
this.histogram = meter.histogramBuilder(metricName)
23-
.setDescription(description)
24-
.setUnit("ns")
25-
.ofLongs()
26-
.build();
27+
this.histogram =
28+
meter
29+
.histogramBuilder(metricName)
30+
.setDescription(description)
31+
.setUnit("ns")
32+
.ofLongs()
33+
.build();
2734
}
2835

2936
@Override
@@ -32,7 +39,10 @@ public void record(MetricRecord<?> metricRecord, Attributes attributes) {
3239
Duration duration = (Duration) metricRecord.value();
3340
histogram.record(duration.toNanos(), attributes);
3441
} else {
35-
logger.log(Level.WARNING, "Invalid value type for duration metric: {}", metricRecord.metric().name());
42+
logger.log(
43+
Level.WARNING,
44+
"Invalid value type for duration metric: {}",
45+
metricRecord.metric().name());
3646
}
3747
}
3848
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.instrumentation.awssdk.v2_2.internal;
27

38
import io.opentelemetry.api.common.Attributes;
49
import io.opentelemetry.api.metrics.LongHistogram;
510
import io.opentelemetry.api.metrics.Meter;
6-
import software.amazon.awssdk.metrics.MetricRecord;
711
import java.util.logging.Level;
812
import java.util.logging.Logger;
13+
import software.amazon.awssdk.metrics.MetricRecord;
914

1015
/**
1116
* Records long value metrics using a LongHistogram.
12-
* <p>
13-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
17+
*
18+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
19+
* at any time.
1420
*/
1521
public class LongHistogramStrategy implements MetricStrategy {
1622
private static final Logger logger = Logger.getLogger(LongHistogramStrategy.class.getName());
1723
private final LongHistogram histogram;
1824

1925
public LongHistogramStrategy(Meter meter, String metricName, String description) {
20-
this.histogram = meter.histogramBuilder(metricName)
21-
.setDescription(description)
22-
.ofLongs()
23-
.build();
26+
this.histogram =
27+
meter.histogramBuilder(metricName).setDescription(description).ofLongs().build();
2428
}
2529

2630
@Override
@@ -29,7 +33,10 @@ public void record(MetricRecord<?> metricRecord, Attributes attributes) {
2933
Number value = (Number) metricRecord.value();
3034
histogram.record(value.longValue(), attributes);
3135
} else {
32-
logger.log(Level.WARNING, "Invalid value type for a LongHistogram metric: {}", metricRecord.metric().name());
36+
logger.log(
37+
Level.WARNING,
38+
"Invalid value type for a LongHistogram metric: {}",
39+
metricRecord.metric().name());
3340
}
3441
}
3542
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
16
package io.opentelemetry.instrumentation.awssdk.v2_2.internal;
27

38
import io.opentelemetry.api.metrics.Meter;
@@ -7,112 +12,165 @@
712

813
/**
914
* Catalogue of AWS-SDK metric definitions that this instrumentation recognizes.
10-
* <p>
11-
* Each enum constant knows:
12-
* (1) the SDK metric identifier
13-
* (2) the scope in the request/attempt/http hierarchy
14-
* (3) how to build the {@link MetricStrategy} that records the metric.
15-
* <p>
16-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
15+
*
16+
* <p>Each enum constant knows: (1) the SDK metric identifier (2) the scope in the
17+
* request/attempt/http hierarchy (3) how to build the {@link MetricStrategy} that records the
18+
* metric.
19+
*
20+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
21+
* at any time.
1722
*/
1823
public enum MetricSpec {
1924
// per-request metrics
2025
API_CALL_DURATION(
2126
CoreMetric.API_CALL_DURATION.name(),
2227
Scope.REQUEST,
23-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "api_call_duration", "The total time taken to finish a request (inclusive of all retries)")
24-
),
28+
(meter, metricPrefix) ->
29+
new DurationStrategy(
30+
meter,
31+
metricPrefix + "api_call_duration",
32+
"The total time taken to finish a request (inclusive of all retries)")),
2533
CREDENTIALS_FETCH_DURATION(
2634
CoreMetric.CREDENTIALS_FETCH_DURATION.name(),
2735
Scope.REQUEST,
28-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "credentials_fetch_duration", "Time taken to fetch AWS signing credentials for the request")
29-
),
36+
(meter, metricPrefix) ->
37+
new DurationStrategy(
38+
meter,
39+
metricPrefix + "credentials_fetch_duration",
40+
"Time taken to fetch AWS signing credentials for the request")),
3041
ENDPOINT_RESOLVE_DURATION(
3142
CoreMetric.ENDPOINT_RESOLVE_DURATION.name(),
3243
Scope.REQUEST,
33-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "endpoint_resolve_duration", "Time it took to resolve the endpoint used for the API call")
34-
),
44+
(meter, metricPrefix) ->
45+
new DurationStrategy(
46+
meter,
47+
metricPrefix + "endpoint_resolve_duration",
48+
"Time it took to resolve the endpoint used for the API call")),
3549
MARSHALLING_DURATION(
3650
CoreMetric.MARSHALLING_DURATION.name(),
3751
Scope.REQUEST,
38-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "marshalling_duration", "Time it takes to marshall an SDK request to an HTTP request")
39-
),
52+
(meter, metricPrefix) ->
53+
new DurationStrategy(
54+
meter,
55+
metricPrefix + "marshalling_duration",
56+
"Time it takes to marshall an SDK request to an HTTP request")),
4057
TOKEN_FETCH_DURATION(
4158
CoreMetric.TOKEN_FETCH_DURATION.name(),
4259
Scope.REQUEST,
43-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "token_fetch_duration", "Time taken to fetch token signing credentials for the request")
44-
),
60+
(meter, metricPrefix) ->
61+
new DurationStrategy(
62+
meter,
63+
metricPrefix + "token_fetch_duration",
64+
"Time taken to fetch token signing credentials for the request")),
4565

4666
// per-attempt metrics
4767
BACKOFF_DELAY_DURATION(
4868
CoreMetric.BACKOFF_DELAY_DURATION.name(),
4969
Scope.ATTEMPT,
50-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "backoff_delay_duration", "Duration of time the SDK waited before this API call attempt")
51-
),
70+
(meter, metricPrefix) ->
71+
new DurationStrategy(
72+
meter,
73+
metricPrefix + "backoff_delay_duration",
74+
"Duration of time the SDK waited before this API call attempt")),
5275
READ_THROUGHPUT(
5376
CoreMetric.READ_THROUGHPUT.name(),
5477
Scope.ATTEMPT,
55-
(meter, metricPrefix) -> new DoubleHistogramStrategy(meter, metricPrefix + "read_throughput", "Read throughput of the client in bytes/second")
56-
),
78+
(meter, metricPrefix) ->
79+
new DoubleHistogramStrategy(
80+
meter,
81+
metricPrefix + "read_throughput",
82+
"Read throughput of the client in bytes/second")),
5783
SERVICE_CALL_DURATION(
5884
CoreMetric.SERVICE_CALL_DURATION.name(),
5985
Scope.ATTEMPT,
60-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "service_call_duration", "Time to connect, send the request and receive the HTTP status code and header")
61-
),
86+
(meter, metricPrefix) ->
87+
new DurationStrategy(
88+
meter,
89+
metricPrefix + "service_call_duration",
90+
"Time to connect, send the request and receive the HTTP status code and header")),
6291
SIGNING_DURATION(
6392
CoreMetric.SIGNING_DURATION.name(),
6493
Scope.ATTEMPT,
65-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "signing_duration", "Time it takes to sign the HTTP request")
66-
),
94+
(meter, metricPrefix) ->
95+
new DurationStrategy(
96+
meter, metricPrefix + "signing_duration", "Time it takes to sign the HTTP request")),
6797
TIME_TO_FIRST_BYTE(
6898
CoreMetric.TIME_TO_FIRST_BYTE.name(),
6999
Scope.ATTEMPT,
70-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "time_to_first_byte", "Elapsed time from sending the HTTP request to receiving the first byte of the headers")
71-
),
100+
(meter, metricPrefix) ->
101+
new DurationStrategy(
102+
meter,
103+
metricPrefix + "time_to_first_byte",
104+
"Elapsed time from sending the HTTP request to receiving the first byte of the headers")),
72105
TIME_TO_LAST_BYTE(
73106
CoreMetric.TIME_TO_LAST_BYTE.name(),
74107
Scope.ATTEMPT,
75-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "time_to_last_byte", "Elapsed time from sending the HTTP request to receiving the last byte of the response")
76-
),
108+
(meter, metricPrefix) ->
109+
new DurationStrategy(
110+
meter,
111+
metricPrefix + "time_to_last_byte",
112+
"Elapsed time from sending the HTTP request to receiving the last byte of the response")),
77113
UNMARSHALLING_DURATION(
78114
CoreMetric.UNMARSHALLING_DURATION.name(),
79115
Scope.ATTEMPT,
80-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "unmarshalling_duration", "Time it takes to unmarshall an HTTP response to an SDK response")
81-
),
116+
(meter, metricPrefix) ->
117+
new DurationStrategy(
118+
meter,
119+
metricPrefix + "unmarshalling_duration",
120+
"Time it takes to unmarshall an HTTP response to an SDK response")),
82121

83122
// HTTP metrics
84123
AVAILABLE_CONCURRENCY(
85124
HttpMetric.AVAILABLE_CONCURRENCY.name(),
86125
Scope.HTTP,
87-
(meter, metricPrefix) -> new LongHistogramStrategy(meter, metricPrefix + "available_concurrency", "Remaining concurrent requests that can be supported without a new connection")
88-
),
126+
(meter, metricPrefix) ->
127+
new LongHistogramStrategy(
128+
meter,
129+
metricPrefix + "available_concurrency",
130+
"Remaining concurrent requests that can be supported without a new connection")),
89131
CONCURRENCY_ACQUIRE_DURATION(
90132
HttpMetric.CONCURRENCY_ACQUIRE_DURATION.name(),
91133
Scope.HTTP,
92-
(meter, metricPrefix) -> new DurationStrategy(meter, metricPrefix + "concurrency_acquire_duration", "Time taken to acquire a channel from the connection pool")
93-
),
134+
(meter, metricPrefix) ->
135+
new DurationStrategy(
136+
meter,
137+
metricPrefix + "concurrency_acquire_duration",
138+
"Time taken to acquire a channel from the connection pool")),
94139
LEASED_CONCURRENCY(
95140
HttpMetric.LEASED_CONCURRENCY.name(),
96141
Scope.HTTP,
97-
(meter, metricPrefix) -> new LongHistogramStrategy(meter, metricPrefix + "leased_concurrency", "Number of requests currently being executed by the HTTP client")
98-
),
142+
(meter, metricPrefix) ->
143+
new LongHistogramStrategy(
144+
meter,
145+
metricPrefix + "leased_concurrency",
146+
"Number of requests currently being executed by the HTTP client")),
99147
MAX_CONCURRENCY(
100148
HttpMetric.MAX_CONCURRENCY.name(),
101149
Scope.HTTP,
102-
(meter, metricPrefix) -> new LongHistogramStrategy(meter, metricPrefix + "max_concurrency", "Maximum number of concurrent requests supported by the HTTP client")
103-
),
150+
(meter, metricPrefix) ->
151+
new LongHistogramStrategy(
152+
meter,
153+
metricPrefix + "max_concurrency",
154+
"Maximum number of concurrent requests supported by the HTTP client")),
104155
PENDING_CONCURRENCY_ACQUIRES(
105156
HttpMetric.PENDING_CONCURRENCY_ACQUIRES.name(),
106157
Scope.HTTP,
107-
(meter, metricPrefix) -> new LongHistogramStrategy(meter, metricPrefix + "pending_concurrency_acquires", "Number of requests waiting for a connection or stream to be available")
108-
);
158+
(meter, metricPrefix) ->
159+
new LongHistogramStrategy(
160+
meter,
161+
metricPrefix + "pending_concurrency_acquires",
162+
"Number of requests waiting for a connection or stream to be available"));
109163

110164
private final String sdkMetricName;
111165
private final Scope scope;
166+
112167
@SuppressWarnings("ImmutableEnumChecker")
113168
private final BiFunction<Meter, String, MetricStrategy> strategyFactory;
114169

115-
MetricSpec(String sdkMetricName, Scope scope, BiFunction<Meter, String, MetricStrategy> strategyFactory) {
170+
MetricSpec(
171+
String sdkMetricName,
172+
Scope scope,
173+
BiFunction<Meter, String, MetricStrategy> strategyFactory) {
116174
this.sdkMetricName = sdkMetricName;
117175
this.scope = scope;
118176
this.strategyFactory = strategyFactory;
@@ -134,7 +192,12 @@ public MetricStrategy create(Meter meter, String metricPrefix) {
134192
/**
135193
* Denotes where in the AWS-SDK metric hierarchy the metric lives.
136194
*
137-
* This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
195+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
196+
* at any time.
138197
*/
139-
public enum Scope { REQUEST, ATTEMPT, HTTP }
198+
public enum Scope {
199+
REQUEST,
200+
ATTEMPT,
201+
HTTP
202+
}
140203
}

0 commit comments

Comments
 (0)