Skip to content

Commit 4351330

Browse files
committed
Add Preview annotations for metrics related classes/methods
1 parent 33b3138 commit 4351330

File tree

18 files changed

+155
-1
lines changed

18 files changed

+155
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.annotations;
17+
18+
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Target;
20+
21+
/**
22+
* Marker interface for preview and experimental APIs. Breaking changes may be
23+
* introduced to elements marked as {@link SdkPreviewApi}. Users of the SDK
24+
* should assume that anything annotated as preview will change or break, and
25+
* <b>should not</b> use them in production.
26+
*/
27+
@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
28+
@SdkProtectedApi
29+
public @interface SdkPreviewApi {
30+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515

1616
package software.amazon.awssdk.metrics;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920
import software.amazon.awssdk.utils.Logger;
2021

2122
/**
2223
* An implementation of {@link MetricPublisher} that writes all published metrics to the logs at the INFO level under the
2324
* {@code software.amazon.awssdk.metrics.LoggingMetricPublisher} namespace.
25+
*
26+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2427
*/
28+
@SdkPreviewApi
2529
@SdkPublicApi
2630
public final class LoggingMetricPublisher implements MetricPublisher {
2731
private static final Logger LOGGER = Logger.loggerFor(LoggingMetricPublisher.class);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515

1616
package software.amazon.awssdk.metrics;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920

2021
/**
2122
* A enum class representing the different types of metric categories in the SDK.
2223
* <p>
2324
* A metric can be tagged with multiple categories. Clients can enable/disable metric collection
2425
* at a {@link MetricCategory} level.
26+
*
27+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2528
*/
29+
@SdkPreviewApi
2630
@SdkPublicApi
2731
public enum MetricCategory {
2832
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@
1919
import java.util.List;
2020
import java.util.stream.Stream;
2121
import java.util.stream.StreamSupport;
22+
import software.amazon.awssdk.annotations.SdkPreviewApi;
2223
import software.amazon.awssdk.annotations.SdkPublicApi;
2324

2425
/**
2526
* An immutable collection of metrics.
27+
*
28+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2629
*/
30+
@SdkPreviewApi
2731
@SdkPublicApi
2832
public interface MetricCollection extends Iterable<MetricRecord<?>> {
2933
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
package software.amazon.awssdk.metrics;
1717

1818
import software.amazon.awssdk.annotations.NotThreadSafe;
19+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1920
import software.amazon.awssdk.annotations.SdkPublicApi;
2021
import software.amazon.awssdk.metrics.internal.DefaultMetricCollector;
2122

2223
/**
2324
* Used to collect metrics reported by the SDK.
25+
*
26+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2427
*/
28+
@SdkPreviewApi
2529
@NotThreadSafe
2630
@SdkPublicApi
2731
public interface MetricCollector {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515

1616
package software.amazon.awssdk.metrics;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920

2021
/**
2122
* The {@code MetricLevel} associated with a {@link SdkMetric}, similar to log levels, defines the 'scenario' in which the metric
2223
* is useful. This makes it easy to reduce the cost of metric publishing (e.g. by setting it to {@link #INFO}), and then increase
2324
* it when additional data level is needed for debugging purposes (e.g. by setting it to {@link #TRACE}.
25+
*
26+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2427
*/
28+
@SdkPreviewApi
2529
@SdkPublicApi
2630
public enum MetricLevel {
2731
/**

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

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

1616
package software.amazon.awssdk.metrics;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920
import software.amazon.awssdk.annotations.ThreadSafe;
2021
import software.amazon.awssdk.metrics.MetricCollection;
@@ -35,7 +36,10 @@
3536
* <p>
3637
* The SDK may invoke methods on the interface from multiple threads
3738
* concurrently so implementations must be threadsafe.
39+
*
40+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
3841
*/
42+
@SdkPreviewApi
3943
@ThreadSafe
4044
@SdkPublicApi
4145
public interface MetricPublisher extends SdkAutoCloseable {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515

1616
package software.amazon.awssdk.metrics;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920

2021
/**
2122
* A container associating a metric and its value.
23+
*
24+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2225
*/
26+
@SdkPreviewApi
2327
@SdkPublicApi
2428
public interface MetricRecord<T> {
2529
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515

1616
package software.amazon.awssdk.metrics;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920

2021
/**
2122
* A metric collector that doesn't do anything.
23+
*
24+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2225
*/
26+
@SdkPreviewApi
2327
@SdkPublicApi
2428
public final class NoOpMetricCollector implements MetricCollector {
2529
private static final NoOpMetricCollector INSTANCE = new NoOpMetricCollector();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
package software.amazon.awssdk.metrics;
1717

1818
import java.util.Set;
19+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1920
import software.amazon.awssdk.annotations.SdkPublicApi;
2021
import software.amazon.awssdk.metrics.internal.DefaultSdkMetric;
2122

2223
/**
2324
* A specific SDK metric.
2425
*
2526
* @param <T> The type for values of this metric.
27+
*
28+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2629
*/
30+
@SdkPreviewApi
2731
@SdkPublicApi
2832
public interface SdkMetric<T> {
2933

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
@SdkPreviewApi
17+
package software.amazon.awssdk.metrics;
18+
19+
import software.amazon.awssdk.annotations.SdkPreviewApi;

core/sdk-core/src/main/java/software/amazon/awssdk/core/RequestOverrideConfiguration.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.TreeMap;
2727
import java.util.function.Consumer;
2828
import software.amazon.awssdk.annotations.Immutable;
29+
import software.amazon.awssdk.annotations.SdkPreviewApi;
2930
import software.amazon.awssdk.annotations.SdkPublicApi;
3031
import software.amazon.awssdk.core.signer.Signer;
3132
import software.amazon.awssdk.metrics.MetricPublisher;
@@ -356,13 +357,26 @@ default B putRawQueryParameter(String name, String value) {
356357
* Sets the metric publishers for publishing the metrics collected for this request. This list supersedes
357358
* the metric publisher set on the client.
358359
*
360+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
361+
*
359362
* @param metricPublisher The list metric publisher for this request.
360363
* @return This object for method chaining.
361364
*/
365+
@SdkPreviewApi
362366
B metricPublishers(List<MetricPublisher> metricPublisher);
363367

368+
/**
369+
* Add a metric publisher to the existing list of previously set publishers to be used for publishing metrics
370+
* for this request.
371+
*
372+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
373+
*
374+
* @param metricPublisher The metric publisher to add.
375+
*/
376+
@SdkPreviewApi
364377
B addMetricPublisher(MetricPublisher metricPublisher);
365378

379+
@SdkPreviewApi
366380
List<MetricPublisher> metricPublishers();
367381

368382
/**

core/sdk-core/src/main/java/software/amazon/awssdk/core/client/config/ClientOverrideConfiguration.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Optional;
2525
import java.util.TreeMap;
2626
import java.util.function.Consumer;
27+
import software.amazon.awssdk.annotations.SdkPreviewApi;
2728
import software.amazon.awssdk.annotations.SdkPublicApi;
2829
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
2930
import software.amazon.awssdk.core.retry.RetryMode;
@@ -421,11 +422,29 @@ default Builder retryPolicy(RetryMode retryMode) {
421422

422423
String defaultProfileName();
423424

424-
425+
/**
426+
* Set the Metric publishers to be use to publish metrics for this client. This overwrites the current list of
427+
* metric publishers set on the builder.
428+
*
429+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
430+
*
431+
* @param metricPublishers The metric publishers.
432+
*/
433+
@SdkPreviewApi
425434
Builder metricPublishers(List<MetricPublisher> metricPublishers);
426435

436+
/**
437+
* Add a metric publisher to the existing list of previously set publishers to be used for publishing metrics
438+
* for this client.
439+
*
440+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
441+
*
442+
* @param metricPublisher The metric publisher to add.
443+
*/
444+
@SdkPreviewApi
427445
Builder addMetricPublisher(MetricPublisher metricPublisher);
428446

447+
@SdkPreviewApi
429448
List<MetricPublisher> metricPublishers();
430449
}
431450

core/sdk-core/src/main/java/software/amazon/awssdk/core/metrics/CoreMetric.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616
package software.amazon.awssdk.core.metrics;
1717

1818
import java.time.Duration;
19+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1920
import software.amazon.awssdk.annotations.SdkPublicApi;
2021
import software.amazon.awssdk.core.retry.RetryPolicy;
2122
import software.amazon.awssdk.metrics.MetricCategory;
2223
import software.amazon.awssdk.metrics.MetricLevel;
2324
import software.amazon.awssdk.metrics.SdkMetric;
2425

26+
/**
27+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
28+
*/
29+
@SdkPreviewApi
2530
@SdkPublicApi
2631
public final class CoreMetric {
2732
/**

http-client-spi/src/main/java/software/amazon/awssdk/http/Http2Metric.java

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

1616
package software.amazon.awssdk.http;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920
import software.amazon.awssdk.metrics.MetricCategory;
2021
import software.amazon.awssdk.metrics.MetricLevel;
@@ -23,7 +24,10 @@
2324
/**
2425
* Metrics collected by HTTP clients for HTTP/2 operations. See {@link HttpMetric} for metrics that are available on both HTTP/1
2526
* and HTTP/2 operations.
27+
*
28+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2629
*/
30+
@SdkPreviewApi
2731
@SdkPublicApi
2832
public final class Http2Metric {
2933
/**

http-client-spi/src/main/java/software/amazon/awssdk/http/HttpMetric.java

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

1616
package software.amazon.awssdk.http;
1717

18+
import software.amazon.awssdk.annotations.SdkPreviewApi;
1819
import software.amazon.awssdk.annotations.SdkPublicApi;
1920
import software.amazon.awssdk.metrics.MetricCategory;
2021
import software.amazon.awssdk.metrics.MetricLevel;
@@ -23,7 +24,10 @@
2324
/**
2425
* Metrics collected by HTTP clients for HTTP/1 and HTTP/2 operations. See {@link Http2Metric} for metrics that are only available
2526
* on HTTP/2 operations.
27+
*
28+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
2629
*/
30+
@SdkPreviewApi
2731
@SdkPublicApi
2832
public final class HttpMetric {
2933
/**

metric-publishers/cloudwatch-metric-publisher/src/main/java/software/amazon/awssdk/metrics/publishers/cloudwatch/CloudWatchMetricPublisher.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.stream.Collectors;
3737
import java.util.stream.Stream;
3838
import software.amazon.awssdk.annotations.Immutable;
39+
import software.amazon.awssdk.annotations.SdkPreviewApi;
3940
import software.amazon.awssdk.annotations.SdkPublicApi;
4041
import software.amazon.awssdk.annotations.ThreadSafe;
4142
import software.amazon.awssdk.core.metrics.CoreMetric;
@@ -151,7 +152,10 @@
151152
*
152153
* <p><b>Warning:</b> Make sure the {@link #close()} this publisher when it is done being used to release all resources it
153154
* consumes. Failure to do so will result in possible thread or file descriptor leaks.
155+
*
156+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
154157
*/
158+
@SdkPreviewApi
155159
@ThreadSafe
156160
@Immutable
157161
@SdkPublicApi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
@SdkPreviewApi
17+
package software.amazon.awssdk.metrics.publishers.cloudwatch;
18+
19+
import software.amazon.awssdk.annotations.SdkPreviewApi;

0 commit comments

Comments
 (0)