Skip to content

Commit d780cba

Browse files
committed
Review comments
1 parent aacca6f commit d780cba

File tree

8 files changed

+30
-43
lines changed

8 files changed

+30
-43
lines changed

core/metrics-spi/src/main/java/software/amazon/awssdk/metrics/MetricCategory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public enum MetricCategory {
3030
* All metrics defined by the SDK are classified under this category at a minimum. If the metrics feature is enabled
3131
* but the category to collect is not, only metrics that are classified under this category are collected by the SDK
3232
*/
33-
DEFAULT("default"),
33+
DEFAULT("Default"),
3434

3535
/**
3636
* Metrics collected at the http client level are classified under this category.
3737
*/
38-
HTTP_CLIENT("httpclient"),
38+
HTTP_CLIENT("HttpClient"),
3939

4040
/**
4141
* Metrics specific to streaming, eventStream APIs are classified under this category.
4242
*/
43-
STREAMING("streaming"),
43+
STREAMING("Streaming"),
4444

4545
/**
4646
* This is an umbrella category (provided for convenience) that records metrics belonging to every category
@@ -49,7 +49,7 @@ public enum MetricCategory {
4949
* Note: Enabling this option is verbose and can be expensive based on the platform the metrics are uploaded to.
5050
* Please make sure you need all this data before using this category.
5151
*/
52-
ALL("all")
52+
ALL("All")
5353

5454
;
5555

core/metrics-spi/src/main/java/software/amazon/awssdk/metrics/MetricCollector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import software.amazon.awssdk.metrics.internal.DefaultMetricCollector;
2121

2222
/**
23-
* Used to collect metrics collected by the SDK.
23+
* Used to collect metrics reported by the SDK.
2424
*/
2525
@NotThreadSafe
2626
@SdkPublicApi
@@ -36,6 +36,7 @@ public interface MetricCollector {
3636
<T> void reportMetric(SdkMetric<T> metric, T data);
3737

3838
/**
39+
* Create a child of this metric collector.
3940
*
4041
* @param name The name of the child collector.
4142
* @return The child collector.

core/metrics-spi/src/main/java/software/amazon/awssdk/metrics/SdkMetric.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,6 @@
1515

1616
package software.amazon.awssdk.metrics;
1717

18-
/*
19-
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
20-
*
21-
* Licensed under the Apache License, Version 2.0 (the "License").
22-
* You may not use this file except in compliance with the License.
23-
* A copy of the License is located at
24-
*
25-
* http://aws.amazon.com/apache2.0
26-
*
27-
* or in the "license" file accompanying this file. This file is distributed
28-
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
29-
* express or implied. See the License for the specific language governing
30-
* permissions and limitations under the License.
31-
*/
32-
3318
import java.util.Set;
3419
import software.amazon.awssdk.annotations.SdkPublicApi;
3520
import software.amazon.awssdk.metrics.internal.DefaultSdkMetric;
@@ -79,8 +64,8 @@ public interface SdkMetric<T> {
7964
*
8065
* @throws IllegalArgumentException If a metric of the same name has already been created.
8166
*/
82-
static <T> SdkMetric<T> of(String name, Class<T> clzz, MetricCategory c1, MetricCategory... cn) {
83-
return DefaultSdkMetric.of(name, clzz, c1, cn);
67+
static <T> SdkMetric<T> create(String name, Class<T> clzz, MetricCategory c1, MetricCategory... cn) {
68+
return DefaultSdkMetric.create(name, clzz, c1, cn);
8469
}
8570

8671
/**
@@ -94,7 +79,7 @@ static <T> SdkMetric<T> of(String name, Class<T> clzz, MetricCategory c1, Metric
9479
*
9580
* @throws IllegalArgumentException If a metric of the same name has already been created.
9681
*/
97-
static <T> SdkMetric<T> of(String name, Class<T> clzz, Set<MetricCategory> categories) {
98-
return DefaultSdkMetric.of(name, clzz, categories);
82+
static <T> SdkMetric<T> create(String name, Class<T> clzz, Set<MetricCategory> categories) {
83+
return DefaultSdkMetric.create(name, clzz, categories);
9984
}
10085
}

core/metrics-spi/src/main/java/software/amazon/awssdk/metrics/internal/DefaultSdkMetric.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ public int hashCode() {
9797
*
9898
* @throws IllegalArgumentException If a metric of the same name has already been created.
9999
*/
100-
public static <T> SdkMetric<T> of(String name, Class<T> clzz, MetricCategory c1, MetricCategory... cn) {
100+
public static <T> SdkMetric<T> create(String name, Class<T> clzz, MetricCategory c1, MetricCategory... cn) {
101101
Stream<MetricCategory> categoryStream = Stream.of(c1);
102102
if (cn != null) {
103103
categoryStream = Stream.concat(categoryStream, Stream.of(cn));
104104
}
105105
Set<MetricCategory> categories = categoryStream.collect(Collectors.toSet());
106-
return of(name, clzz, categories);
106+
return create(name, clzz, categories);
107107
}
108108

109109
/**
@@ -117,7 +117,7 @@ public static <T> SdkMetric<T> of(String name, Class<T> clzz, MetricCategory c1,
117117
*
118118
* @throws IllegalArgumentException If a metric of the same name has already been created.
119119
*/
120-
public static <T> SdkMetric<T> of(String name, Class<T> clzz, Set<MetricCategory> categories) {
120+
public static <T> SdkMetric<T> create(String name, Class<T> clzz, Set<MetricCategory> categories) {
121121
Validate.noNullElements(categories, "categories must not contain null elements");
122122
SdkMetric<T> event = new DefaultSdkMetric<>(name, clzz, categories);
123123
if (SDK_METRICS.putIfAbsent(event, Boolean.TRUE) != null) {

core/metrics-spi/src/test/java/software/amazon/awssdk/metrics/internal/DefaultMetricCollectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import software.amazon.awssdk.metrics.SdkMetric;
3232

3333
public class DefaultMetricCollectionTest {
34-
private static final SdkMetric<Integer> M1 = SdkMetric.of("m1", Integer.class, MetricCategory.DEFAULT);
34+
private static final SdkMetric<Integer> M1 = SdkMetric.create("m1", Integer.class, MetricCategory.DEFAULT);
3535

3636
@AfterClass
3737
public static void teardown() {

core/metrics-spi/src/test/java/software/amazon/awssdk/metrics/internal/DefaultMetricCollectorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import software.amazon.awssdk.metrics.SdkMetric;
2828

2929
public class DefaultMetricCollectorTest {
30-
private static final SdkMetric<Integer> M1 = SdkMetric.of("m1", Integer.class, MetricCategory.DEFAULT);
30+
private static final SdkMetric<Integer> M1 = SdkMetric.create("m1", Integer.class, MetricCategory.DEFAULT);
3131

3232
@Rule
3333
public ExpectedException thrown = ExpectedException.none();
@@ -72,6 +72,7 @@ public void testCollect_returnedCollectionContainsAllChildren() {
7272
@Test
7373
public void testReportMetric_collected_throws() {
7474
thrown.expect(IllegalStateException.class);
75+
thrown.expectMessage("This collector has already been closed");
7576

7677
MetricCollector collector = MetricCollector.create("collector");
7778
collector.collect();

core/metrics-spi/src/test/java/software/amazon/awssdk/metrics/internal/DefaultSdkMetricRecordTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class DefaultSdkMetricRecordTest {
2828
@Test
2929
public void testGetters() {
30-
SdkMetric<Integer> event = SdkMetric.of("foo", Integer.class, MetricCategory.DEFAULT);
30+
SdkMetric<Integer> event = SdkMetric.create("foo", Integer.class, MetricCategory.DEFAULT);
3131

3232
MetricRecord<Integer> record = new DefaultMetricRecord<>(event, 2);
3333

core/metrics-spi/src/test/java/software/amazon/awssdk/metrics/internal/DefaultSdkMetricTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void methodSetup() {
3737

3838
@Test
3939
public void testOf_variadicOverload_createdProperly() {
40-
SdkMetric<Integer> event = SdkMetric.of("event", Integer.class, MetricCategory.DEFAULT);
40+
SdkMetric<Integer> event = SdkMetric.create("event", Integer.class, MetricCategory.DEFAULT);
4141

4242
assertThat(event.categories()).containsExactly(MetricCategory.DEFAULT);
4343
assertThat(event.name()).isEqualTo("event");
@@ -46,7 +46,7 @@ public void testOf_variadicOverload_createdProperly() {
4646

4747
@Test
4848
public void testOf_setOverload_createdProperly() {
49-
SdkMetric<Integer> event = SdkMetric.of("event", Integer.class, Stream.of(MetricCategory.DEFAULT)
49+
SdkMetric<Integer> event = SdkMetric.create("event", Integer.class, Stream.of(MetricCategory.DEFAULT)
5050
.collect(Collectors.toSet()));
5151

5252
assertThat(event.categories()).containsExactly(MetricCategory.DEFAULT);
@@ -58,33 +58,33 @@ public void testOf_setOverload_createdProperly() {
5858
public void testOf_variadicOverload_c1Null_throws() {
5959
thrown.expect(IllegalArgumentException.class);
6060
thrown.expectMessage("must not contain null elements");
61-
SdkMetric.of("event", Integer.class, (MetricCategory) null);
61+
SdkMetric.create("event", Integer.class, (MetricCategory) null);
6262
}
6363

6464
@Test
6565
public void testOf_variadicOverload_c1NotNull_cnNull_doesNotThrow() {
66-
SdkMetric.of("event", Integer.class, MetricCategory.DEFAULT, null);
66+
SdkMetric.create("event", Integer.class, MetricCategory.DEFAULT, null);
6767
}
6868

6969
@Test
7070
public void testOf_variadicOverload_cnContainsNull_throws() {
7171
thrown.expect(IllegalArgumentException.class);
7272
thrown.expectMessage("must not contain null elements");
73-
SdkMetric.of("event", Integer.class, MetricCategory.DEFAULT, new MetricCategory[]{ null });
73+
SdkMetric.create("event", Integer.class, MetricCategory.DEFAULT, new MetricCategory[]{ null });
7474
}
7575

7676
@Test
7777
public void testOf_setOverload_null_throws() {
7878
thrown.expect(NullPointerException.class);
7979
thrown.expectMessage("object is null");
80-
SdkMetric.of("event", Integer.class, (Set<MetricCategory>) null);
80+
SdkMetric.create("event", Integer.class, (Set<MetricCategory>) null);
8181
}
8282

8383
@Test
8484
public void testOf_setOverload_nullElement_throws() {
8585
thrown.expect(IllegalArgumentException.class);
8686
thrown.expectMessage("categories must not contain null elements");
87-
SdkMetric.of("event", Integer.class, Stream.of((MetricCategory) null).collect(Collectors.toSet()));
87+
SdkMetric.create("event", Integer.class, Stream.of((MetricCategory) null).collect(Collectors.toSet()));
8888
}
8989

9090
@Test
@@ -94,8 +94,8 @@ public void testOf_namePreviouslyUsed_throws() {
9494
thrown.expect(IllegalArgumentException.class);
9595
thrown.expectMessage(fooName + " has already been created");
9696

97-
SdkMetric.of(fooName, Integer.class, MetricCategory.DEFAULT);
98-
SdkMetric.of(fooName, Integer.class, MetricCategory.DEFAULT);
97+
SdkMetric.create(fooName, Integer.class, MetricCategory.DEFAULT);
98+
SdkMetric.create(fooName, Integer.class, MetricCategory.DEFAULT);
9999
}
100100

101101
@Test
@@ -105,8 +105,8 @@ public void testOf_namePreviouslyUsed_differentArgs_throws() {
105105
thrown.expect(IllegalArgumentException.class);
106106
thrown.expectMessage(fooName + " has already been created");
107107

108-
SdkMetric.of(fooName, Integer.class, MetricCategory.DEFAULT);
109-
SdkMetric.of(fooName, Long.class, MetricCategory.STREAMING);
108+
SdkMetric.create(fooName, Integer.class, MetricCategory.DEFAULT);
109+
SdkMetric.create(fooName, Long.class, MetricCategory.STREAMING);
110110
}
111111

112112
@Test
@@ -116,9 +116,9 @@ public void testOf_namePreviouslyUsed_doesNotReplaceExisting() {
116116
thrown.expect(IllegalArgumentException.class);
117117
thrown.expectMessage(fooName + " has already been created");
118118

119-
SdkMetric.of(fooName, Integer.class, MetricCategory.DEFAULT);
119+
SdkMetric.create(fooName, Integer.class, MetricCategory.DEFAULT);
120120
try {
121-
SdkMetric.of(fooName, Long.class, MetricCategory.STREAMING);
121+
SdkMetric.create(fooName, Long.class, MetricCategory.STREAMING);
122122
} finally {
123123
SdkMetric<?> fooMetric = DefaultSdkMetric.declaredEvents()
124124
.stream()

0 commit comments

Comments
 (0)