Skip to content

Commit cbab60c

Browse files
authored
Refactor http, grpc senders and promote to public API (#7782)
1 parent aa2ca12 commit cbab60c

97 files changed

Lines changed: 1800 additions & 1852 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,109 @@
11
Comparing source compatibility of opentelemetry-sdk-common-1.59.0-SNAPSHOT.jar against opentelemetry-sdk-common-1.58.0.jar
2-
No changes.
2+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.Compressor (not serializable)
3+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
4+
+++ NEW SUPERCLASS: java.lang.Object
5+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.io.OutputStream compress(java.io.OutputStream)
6+
+++ NEW EXCEPTION: java.io.IOException
7+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getEncoding()
8+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.GrpcResponse (not serializable)
9+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
10+
+++ NEW SUPERCLASS: java.lang.Object
11+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) byte[] getResponseMessage()
12+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.GrpcStatusCode getStatusCode()
13+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getStatusDescription()
14+
+++ NEW ANNOTATION: javax.annotation.Nullable
15+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.GrpcSender (not serializable)
16+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
17+
+++ NEW SUPERCLASS: java.lang.Object
18+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) void send(io.opentelemetry.sdk.common.export.MessageWriter, java.util.function.Consumer<io.opentelemetry.sdk.common.export.GrpcResponse>, java.util.function.Consumer<java.lang.Throwable>)
19+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.CompletableResultCode shutdown()
20+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.GrpcSenderConfig (not serializable)
21+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
22+
+++ NEW SUPERCLASS: java.lang.Object
23+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.Compressor getCompressor()
24+
+++ NEW ANNOTATION: javax.annotation.Nullable
25+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getConnectTimeout()
26+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.net.URI getEndpoint()
27+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.concurrent.ExecutorService getExecutorService()
28+
+++ NEW ANNOTATION: javax.annotation.Nullable
29+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getFullMethodName()
30+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.function.Supplier<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> getHeadersSupplier()
31+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy getRetryPolicy()
32+
+++ NEW ANNOTATION: javax.annotation.Nullable
33+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.SSLContext getSslContext()
34+
+++ NEW ANNOTATION: javax.annotation.Nullable
35+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getTimeout()
36+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.X509TrustManager getTrustManager()
37+
+++ NEW ANNOTATION: javax.annotation.Nullable
38+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.GrpcSenderProvider (not serializable)
39+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
40+
+++ NEW SUPERCLASS: java.lang.Object
41+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.GrpcSender createSender(io.opentelemetry.sdk.common.export.GrpcSenderConfig)
42+
+++ NEW ENUM: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode (compatible)
43+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
44+
+++ NEW INTERFACE: java.lang.constant.Constable
45+
+++ NEW INTERFACE: java.lang.Comparable
46+
+++ NEW INTERFACE: java.io.Serializable
47+
+++ NEW SUPERCLASS: java.lang.Enum
48+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode RESOURCE_EXHAUSTED
49+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode ALREADY_EXISTS
50+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode UNIMPLEMENTED
51+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode FAILED_PRECONDITION
52+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode NOT_FOUND
53+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode DEADLINE_EXCEEDED
54+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode OUT_OF_RANGE
55+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode UNAUTHENTICATED
56+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode CANCELLED
57+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode DATA_LOSS
58+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode INTERNAL
59+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode UNAVAILABLE
60+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode UNKNOWN
61+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode ABORTED
62+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode OK
63+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode INVALID_ARGUMENT
64+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.common.export.GrpcStatusCode PERMISSION_DENIED
65+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.GrpcStatusCode fromValue(int)
66+
+++ NEW METHOD: PUBLIC(+) int getValue()
67+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.GrpcStatusCode valueOf(java.lang.String)
68+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.GrpcStatusCode[] values()
69+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.HttpResponse (not serializable)
70+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
71+
+++ NEW SUPERCLASS: java.lang.Object
72+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) byte[] getResponseBody()
73+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) int getStatusCode()
74+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getStatusMessage()
75+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.HttpSender (not serializable)
76+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
77+
+++ NEW SUPERCLASS: java.lang.Object
78+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) void send(io.opentelemetry.sdk.common.export.MessageWriter, java.util.function.Consumer<io.opentelemetry.sdk.common.export.HttpResponse>, java.util.function.Consumer<java.lang.Throwable>)
79+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.CompletableResultCode shutdown()
80+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.HttpSenderConfig (not serializable)
81+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
82+
+++ NEW SUPERCLASS: java.lang.Object
83+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.Compressor getCompressor()
84+
+++ NEW ANNOTATION: javax.annotation.Nullable
85+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getConnectTimeout()
86+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getContentType()
87+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.net.URI getEndpoint()
88+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.concurrent.ExecutorService getExecutorService()
89+
+++ NEW ANNOTATION: javax.annotation.Nullable
90+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.function.Supplier<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> getHeadersSupplier()
91+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.ProxyOptions getProxyOptions()
92+
+++ NEW ANNOTATION: javax.annotation.Nullable
93+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy getRetryPolicy()
94+
+++ NEW ANNOTATION: javax.annotation.Nullable
95+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.SSLContext getSslContext()
96+
+++ NEW ANNOTATION: javax.annotation.Nullable
97+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getTimeout()
98+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.X509TrustManager getTrustManager()
99+
+++ NEW ANNOTATION: javax.annotation.Nullable
100+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.HttpSenderProvider (not serializable)
101+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
102+
+++ NEW SUPERCLASS: java.lang.Object
103+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.HttpSender createSender(io.opentelemetry.sdk.common.export.HttpSenderConfig)
104+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.MessageWriter (not serializable)
105+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
106+
+++ NEW SUPERCLASS: java.lang.Object
107+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) int getContentLength()
108+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) void writeMessage(java.io.OutputStream)
109+
+++ NEW EXCEPTION: java.io.IOException

exporters/common/src/main/java/io/opentelemetry/exporter/internal/FailedExportException.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
package io.opentelemetry.exporter.internal;
77

8-
import io.opentelemetry.exporter.internal.grpc.GrpcResponse;
9-
import io.opentelemetry.exporter.internal.http.HttpSender;
8+
import io.opentelemetry.sdk.common.export.GrpcResponse;
9+
import io.opentelemetry.sdk.common.export.HttpResponse;
1010
import javax.annotation.Nullable;
1111

1212
/**
@@ -24,7 +24,7 @@ private FailedExportException(@Nullable Throwable cause) {
2424
}
2525

2626
/** Indicates an HTTP export failed after receiving a response from the server. */
27-
public static HttpExportException httpFailedWithResponse(HttpSender.Response response) {
27+
public static HttpExportException httpFailedWithResponse(HttpResponse response) {
2828
return new HttpExportException(response, null);
2929
}
3030

@@ -56,10 +56,10 @@ public static final class HttpExportException extends FailedExportException {
5656

5757
private static final long serialVersionUID = -6787390183017184775L;
5858

59-
@Nullable private final HttpSender.Response response;
59+
@Nullable private final HttpResponse response;
6060
@Nullable private final Throwable cause;
6161

62-
private HttpExportException(@Nullable HttpSender.Response response, @Nullable Throwable cause) {
62+
private HttpExportException(@Nullable HttpResponse response, @Nullable Throwable cause) {
6363
super(cause);
6464
this.response = response;
6565
this.cause = cause;
@@ -75,7 +75,7 @@ public boolean failedWithResponse() {
7575
* export failed exceptionally with no response.
7676
*/
7777
@Nullable
78-
public HttpSender.Response getResponse() {
78+
public HttpResponse getResponse() {
7979
return response;
8080
}
8181

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

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

66
package io.opentelemetry.exporter.internal;
77

8-
import io.opentelemetry.exporter.internal.grpc.GrpcExporterUtil;
8+
import io.opentelemetry.sdk.common.export.GrpcStatusCode;
99
import java.util.Arrays;
1010
import java.util.Collections;
1111
import java.util.HashSet;
@@ -24,13 +24,13 @@ public final class RetryUtil {
2424

2525
static {
2626
Set<Integer> retryableGrpcStatusCodes = new HashSet<>();
27-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_CANCELLED);
28-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_DEADLINE_EXCEEDED);
29-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_RESOURCE_EXHAUSTED);
30-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_ABORTED);
31-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_OUT_OF_RANGE);
32-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_UNAVAILABLE);
33-
retryableGrpcStatusCodes.add(GrpcExporterUtil.GRPC_STATUS_DATA_LOSS);
27+
retryableGrpcStatusCodes.add(GrpcStatusCode.CANCELLED.getValue());
28+
retryableGrpcStatusCodes.add(GrpcStatusCode.DEADLINE_EXCEEDED.getValue());
29+
retryableGrpcStatusCodes.add(GrpcStatusCode.RESOURCE_EXHAUSTED.getValue());
30+
retryableGrpcStatusCodes.add(GrpcStatusCode.ABORTED.getValue());
31+
retryableGrpcStatusCodes.add(GrpcStatusCode.OUT_OF_RANGE.getValue());
32+
retryableGrpcStatusCodes.add(GrpcStatusCode.UNAVAILABLE.getValue());
33+
retryableGrpcStatusCodes.add(GrpcStatusCode.DATA_LOSS.getValue());
3434
RETRYABLE_GRPC_STATUS_CODES =
3535
Collections.unmodifiableSet(
3636
retryableGrpcStatusCodes.stream().map(Object::toString).collect(Collectors.toSet()));

exporters/common/src/main/java/io/opentelemetry/exporter/internal/compression/CompressorProvider.java

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

exporters/common/src/main/java/io/opentelemetry/exporter/internal/compression/CompressorUtil.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static java.util.stream.Collectors.joining;
1010

1111
import io.opentelemetry.common.ComponentLoader;
12+
import io.opentelemetry.sdk.common.export.Compressor;
1213
import java.util.HashMap;
1314
import java.util.Map;
1415
import java.util.Set;
@@ -19,11 +20,10 @@
1920
*
2021
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
2122
* at any time.
22-
*
23-
* @see CompressorProvider
2423
*/
2524
public final class CompressorUtil {
2625

26+
private static final GzipCompressor gzipCompressor = new GzipCompressor();
2727
private static final Map<String, Compressor> compressorRegistry =
2828
buildCompressorRegistry(
2929
ComponentLoader.forClassLoader(CompressorUtil.class.getClassLoader()));
@@ -67,12 +67,11 @@ public static Compressor validateAndResolveCompressor(
6767

6868
private static Map<String, Compressor> buildCompressorRegistry(ComponentLoader componentLoader) {
6969
Map<String, Compressor> compressors = new HashMap<>();
70-
for (CompressorProvider spi : componentLoader.load(CompressorProvider.class)) {
71-
Compressor compressor = spi.getInstance();
70+
for (Compressor compressor : componentLoader.load(Compressor.class)) {
7271
compressors.put(compressor.getEncoding(), compressor);
7372
}
7473
// Hardcode gzip compressor
75-
compressors.put(GzipCompressor.getInstance().getEncoding(), GzipCompressor.getInstance());
74+
compressors.put(gzipCompressor.getEncoding(), gzipCompressor);
7675
return compressors;
7776
}
7877
}

exporters/common/src/main/java/io/opentelemetry/exporter/internal/compression/GzipCompressor.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

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

8+
import io.opentelemetry.sdk.common.export.Compressor;
89
import java.io.IOException;
910
import java.io.OutputStream;
1011
import java.util.zip.GZIPOutputStream;
@@ -17,13 +18,7 @@
1718
*/
1819
public final class GzipCompressor implements Compressor {
1920

20-
private static final GzipCompressor INSTANCE = new GzipCompressor();
21-
22-
private GzipCompressor() {}
23-
24-
public static GzipCompressor getInstance() {
25-
return INSTANCE;
26-
}
21+
public GzipCompressor() {}
2722

2823
@Override
2924
public String getEncoding() {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.internal.grpc;
7+
8+
import io.opentelemetry.sdk.common.export.GrpcSenderConfig;
9+
import javax.annotation.Nullable;
10+
11+
/**
12+
* Extended {@link GrpcSenderConfig} with internal / experimental APIs.
13+
*
14+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
15+
* at any time.
16+
*/
17+
public interface ExtendedGrpcSenderConfig extends GrpcSenderConfig {
18+
19+
@Nullable
20+
Object getMangedChannel();
21+
}

0 commit comments

Comments
 (0)