Skip to content

Commit 7bd06ef

Browse files
authored
Stabilize RetryPolicy API for OTLP exporters (#5524)
1 parent b5b02eb commit 7bd06ef

File tree

43 files changed

+262
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+262
-339
lines changed
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
Comparing source compatibility of against
2-
No changes.
2+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder (not serializable)
3+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
4+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder setRetryPolicy(io.opentelemetry.sdk.common.export.RetryPolicy)
5+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder (not serializable)
6+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
7+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder setRetryPolicy(io.opentelemetry.sdk.common.export.RetryPolicy)
8+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder (not serializable)
9+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
10+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder setRetryPolicy(io.opentelemetry.sdk.common.export.RetryPolicy)
11+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder (not serializable)
12+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
13+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder setRetryPolicy(io.opentelemetry.sdk.common.export.RetryPolicy)
14+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder (not serializable)
15+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
16+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder setRetryPolicy(io.opentelemetry.sdk.common.export.RetryPolicy)
17+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder (not serializable)
18+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
19+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder setRetryPolicy(io.opentelemetry.sdk.common.export.RetryPolicy)
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
Comparing source compatibility of against
2-
No changes.
2+
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy (not serializable)
3+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
4+
+++ NEW SUPERCLASS: java.lang.Object
5+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.RetryPolicy$RetryPolicyBuilder builder()
6+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) double getBackoffMultiplier()
7+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.RetryPolicy getDefault()
8+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getInitialBackoff()
9+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) int getMaxAttempts()
10+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getMaxBackoff()
11+
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) STATIC(+) io.opentelemetry.sdk.common.export.RetryPolicy$RetryPolicyBuilder (not serializable)
12+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
13+
+++ NEW SUPERCLASS: java.lang.Object
14+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.export.RetryPolicy build()
15+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy$RetryPolicyBuilder setBackoffMultiplier(double)
16+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy$RetryPolicyBuilder setInitialBackoff(java.time.Duration)
17+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy$RetryPolicyBuilder setMaxAttempts(int)
18+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy$RetryPolicyBuilder setMaxBackoff(java.time.Duration)

exporters/common/src/main/java/io/opentelemetry/exporter/internal/grpc/GrpcExporterBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import io.opentelemetry.exporter.internal.marshal.Marshaler;
1919
import io.opentelemetry.exporter.internal.okhttp.OkHttpUtil;
2020
import io.opentelemetry.exporter.internal.retry.RetryInterceptor;
21-
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
21+
import io.opentelemetry.sdk.common.export.RetryPolicy;
2222
import java.net.URI;
2323
import java.time.Duration;
2424
import java.util.Arrays;

exporters/common/src/main/java/io/opentelemetry/exporter/internal/grpc/ManagedChannelUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
import io.grpc.ManagedChannel;
1111
import io.grpc.ManagedChannelBuilder;
12-
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
1312
import io.opentelemetry.exporter.internal.retry.RetryUtil;
1413
import io.opentelemetry.sdk.common.CompletableResultCode;
14+
import io.opentelemetry.sdk.common.export.RetryPolicy;
1515
import java.util.Collections;
1616
import java.util.HashMap;
1717
import java.util.List;

exporters/common/src/main/java/io/opentelemetry/exporter/internal/http/HttpExporterBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import io.opentelemetry.exporter.internal.TlsConfigHelper;
1212
import io.opentelemetry.exporter.internal.auth.Authenticator;
1313
import io.opentelemetry.exporter.internal.marshal.Marshaler;
14-
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
14+
import io.opentelemetry.sdk.common.export.RetryPolicy;
1515
import java.net.URI;
1616
import java.time.Duration;
1717
import java.util.Collections;

exporters/common/src/main/java/io/opentelemetry/exporter/internal/http/HttpSenderProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package io.opentelemetry.exporter.internal.http;
77

88
import io.opentelemetry.exporter.internal.auth.Authenticator;
9-
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
9+
import io.opentelemetry.sdk.common.export.RetryPolicy;
1010
import java.util.Map;
1111
import java.util.function.Supplier;
1212
import javax.annotation.Nullable;

exporters/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryInterceptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.exporter.internal.retry;
77

8+
import io.opentelemetry.sdk.common.export.RetryPolicy;
89
import java.io.IOException;
910
import java.net.SocketTimeoutException;
1011
import java.util.Locale;

exporters/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryPolicy.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

exporters/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryPolicyBuilder.java

Lines changed: 0 additions & 69 deletions
This file was deleted.

exporters/common/src/main/java/io/opentelemetry/exporter/internal/retry/RetryUtil.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
package io.opentelemetry.exporter.internal.retry;
77

8-
import io.opentelemetry.exporter.internal.grpc.GrpcExporterBuilder;
98
import io.opentelemetry.exporter.internal.grpc.GrpcStatusUtil;
10-
import io.opentelemetry.exporter.internal.http.HttpExporterBuilder;
11-
import java.lang.reflect.Field;
129
import java.util.Arrays;
1310
import java.util.Collections;
1411
import java.util.HashSet;
@@ -47,29 +44,4 @@ public static Set<String> retryableGrpcStatusCodes() {
4744
public static Set<Integer> retryableHttpResponseCodes() {
4845
return RETRYABLE_HTTP_STATUS_CODES;
4946
}
50-
51-
/**
52-
* Reflectively access a {@link GrpcExporterBuilder}, or {@link HttpExporterBuilder} instance in
53-
* field called "delegate" of the instance, and set the {@link RetryPolicy}.
54-
*
55-
* @throws IllegalArgumentException if the instance does not contain a field called "delegate" of
56-
* a supported type.
57-
*/
58-
public static void setRetryPolicyOnDelegate(Object instance, RetryPolicy retryPolicy) {
59-
try {
60-
Field field = instance.getClass().getDeclaredField("delegate");
61-
field.setAccessible(true);
62-
Object value = field.get(instance);
63-
if (value instanceof GrpcExporterBuilder) {
64-
((GrpcExporterBuilder<?>) value).setRetryPolicy(retryPolicy);
65-
} else if (value instanceof HttpExporterBuilder) {
66-
((HttpExporterBuilder<?>) value).setRetryPolicy(retryPolicy);
67-
} else {
68-
throw new IllegalArgumentException(
69-
"delegate field is not type DefaultGrpcExporterBuilder or OkHttpGrpcExporterBuilder");
70-
}
71-
} catch (NoSuchFieldException | IllegalAccessException e) {
72-
throw new IllegalArgumentException("Unable to access delegate reflectively.", e);
73-
}
74-
}
7547
}

exporters/common/src/test/java/io/opentelemetry/exporter/internal/grpc/ManagedChannelUtilTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import com.fasterxml.jackson.databind.ObjectMapper;
1111
import io.grpc.ManagedChannelBuilder;
12-
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
12+
import io.opentelemetry.sdk.common.export.RetryPolicy;
1313
import java.util.Map;
1414
import org.junit.jupiter.api.Test;
1515
import org.skyscreamer.jsonassert.JSONAssert;

exporters/common/src/test/java/io/opentelemetry/exporter/internal/retry/RetryInterceptorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.linecorp.armeria.common.HttpResponse;
2222
import com.linecorp.armeria.common.HttpStatus;
2323
import com.linecorp.armeria.testing.junit5.server.mock.MockWebServerExtension;
24+
import io.opentelemetry.sdk.common.export.RetryPolicy;
2425
import java.io.IOException;
2526
import java.net.SocketTimeoutException;
2627
import java.time.Duration;

exporters/common/src/test/java/io/opentelemetry/exporter/internal/retry/RetryUtilTest.java

Lines changed: 0 additions & 69 deletions
This file was deleted.

exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporterBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.opentelemetry.exporter.internal.http.HttpExporterBuilder;
1414
import io.opentelemetry.exporter.internal.otlp.logs.LogsRequestMarshaler;
1515
import io.opentelemetry.exporter.otlp.internal.OtlpUserAgent;
16+
import io.opentelemetry.sdk.common.export.RetryPolicy;
1617
import java.time.Duration;
1718
import java.util.concurrent.TimeUnit;
1819
import javax.net.ssl.SSLContext;
@@ -113,6 +114,17 @@ public OtlpHttpLogRecordExporterBuilder setSslContext(
113114
return this;
114115
}
115116

117+
/**
118+
* Ses the retry policy. Retry is disabled by default.
119+
*
120+
* @since 1.28.0
121+
*/
122+
public OtlpHttpLogRecordExporterBuilder setRetryPolicy(RetryPolicy retryPolicy) {
123+
requireNonNull(retryPolicy, "retryPolicy");
124+
delegate.setRetryPolicy(retryPolicy);
125+
return this;
126+
}
127+
116128
/**
117129
* Sets the {@link MeterProvider} to use to collect metrics related to export. If not set, uses
118130
* {@link GlobalOpenTelemetry#getMeterProvider()}.

exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/http/metrics/OtlpHttpMetricExporterBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.opentelemetry.exporter.internal.http.HttpExporterBuilder;
1313
import io.opentelemetry.exporter.internal.otlp.metrics.MetricsRequestMarshaler;
1414
import io.opentelemetry.exporter.otlp.internal.OtlpUserAgent;
15+
import io.opentelemetry.sdk.common.export.RetryPolicy;
1516
import io.opentelemetry.sdk.metrics.InstrumentType;
1617
import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector;
1718
import io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector;
@@ -157,6 +158,17 @@ public OtlpHttpMetricExporterBuilder setDefaultAggregationSelector(
157158
return this;
158159
}
159160

161+
/**
162+
* Ses the retry policy. Retry is disabled by default.
163+
*
164+
* @since 1.28.0
165+
*/
166+
public OtlpHttpMetricExporterBuilder setRetryPolicy(RetryPolicy retryPolicy) {
167+
requireNonNull(retryPolicy, "retryPolicy");
168+
delegate.setRetryPolicy(retryPolicy);
169+
return this;
170+
}
171+
160172
OtlpHttpMetricExporterBuilder exportAsJson() {
161173
delegate.exportAsJson();
162174
return this;

0 commit comments

Comments
 (0)