-
Notifications
You must be signed in to change notification settings - Fork 934
Refactor http, grpc senders and promote to public API #7782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jack-berg
wants to merge
12
commits into
open-telemetry:main
Choose a base branch
from
jack-berg:public-sender-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,734
−1,848
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b4ef764
Refactor http, grpc senders and promote to public API
jack-berg fd565bb
PR feedback
jack-berg ee21659
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 5336b6b
Common MessageWriter abstraction
jack-berg b8cf047
Read response before accessing trailers
jack-berg 4a4757e
Fix build
jack-berg e35c950
PR feedback
jack-berg c732674
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg a392cd0
Finish renaming to fullMethodName
jack-berg 0a153ec
Require HttpResponse#getResponseBody(), GrpcResponse#getResponseMessage
jack-berg 1980f2c
Remove CompressorProvider, making Compressor SPI
jack-berg 5dbc218
timeout nanos to duration
jack-berg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
109 changes: 108 additions & 1 deletion
109
docs/apidiffs/current_vs_latest/opentelemetry-exporter-common.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,109 @@ | ||
| Comparing source compatibility of opentelemetry-exporter-common-1.59.0-SNAPSHOT.jar against opentelemetry-exporter-common-1.58.0.jar | ||
| No changes. | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.compressor.Compressor (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.io.OutputStream compress(java.io.OutputStream) | ||
| +++ NEW EXCEPTION: java.io.IOException | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getEncoding() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.grpc.GrpcResponse (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) byte[] getResponseMessage() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.grpc.GrpcStatusCode getStatusCode() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getStatusDescription() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.grpc.GrpcSender (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) void send(io.opentelemetry.exporter.marshal.MessageWriter, java.util.function.Consumer<io.opentelemetry.exporter.grpc.GrpcResponse>, java.util.function.Consumer<java.lang.Throwable>) | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.CompletableResultCode shutdown() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.grpc.GrpcSenderConfig (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.compressor.Compressor getCompressor() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getConnectTimeout() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.net.URI getEndpoint() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.concurrent.ExecutorService getExecutorService() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getFullMethodName() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.function.Supplier<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> getHeadersSupplier() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy getRetryPolicy() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.SSLContext getSslContext() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getTimeout() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.X509TrustManager getTrustManager() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.grpc.GrpcSenderProvider (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.grpc.GrpcSender createSender(io.opentelemetry.exporter.grpc.GrpcSenderConfig) | ||
| +++ NEW ENUM: PUBLIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode (compatible) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW INTERFACE: java.lang.constant.Constable | ||
| +++ NEW INTERFACE: java.lang.Comparable | ||
| +++ NEW INTERFACE: java.io.Serializable | ||
| +++ NEW SUPERCLASS: java.lang.Enum | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode RESOURCE_EXHAUSTED | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode ALREADY_EXISTS | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode UNIMPLEMENTED | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode FAILED_PRECONDITION | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode NOT_FOUND | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode DEADLINE_EXCEEDED | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode OUT_OF_RANGE | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode UNAUTHENTICATED | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode CANCELLED | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode DATA_LOSS | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode INTERNAL | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode UNAVAILABLE | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode UNKNOWN | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode ABORTED | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode OK | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode INVALID_ARGUMENT | ||
| +++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.exporter.grpc.GrpcStatusCode PERMISSION_DENIED | ||
| +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.exporter.grpc.GrpcStatusCode fromValue(int) | ||
| +++ NEW METHOD: PUBLIC(+) int getValue() | ||
| +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.exporter.grpc.GrpcStatusCode valueOf(java.lang.String) | ||
| +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.exporter.grpc.GrpcStatusCode[] values() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.http.HttpResponse (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) byte[] getResponseBody() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) int getStatusCode() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getStatusMessage() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.http.HttpSender (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) void send(io.opentelemetry.exporter.marshal.MessageWriter, java.util.function.Consumer<io.opentelemetry.exporter.http.HttpResponse>, java.util.function.Consumer<java.lang.Throwable>) | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.CompletableResultCode shutdown() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.http.HttpSenderConfig (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.compressor.Compressor getCompressor() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getConnectTimeout() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getContentType() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.net.URI getEndpoint() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.concurrent.ExecutorService getExecutorService() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.function.Supplier<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> getHeadersSupplier() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.ProxyOptions getProxyOptions() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.export.RetryPolicy getRetryPolicy() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.SSLContext getSslContext() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.time.Duration getTimeout() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) javax.net.ssl.X509TrustManager getTrustManager() | ||
| +++ NEW ANNOTATION: javax.annotation.Nullable | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.http.HttpSenderProvider (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.http.HttpSender createSender(io.opentelemetry.exporter.http.HttpSenderConfig) | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.exporter.marshal.MessageWriter (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) int getContentLength() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) void writeMessage(java.io.OutputStream) | ||
| +++ NEW EXCEPTION: java.io.IOException |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
exporters/common/src/main/java/io/opentelemetry/exporter/grpc/GrpcResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.grpc; | ||
|
|
||
| import io.opentelemetry.exporter.marshal.MessageWriter; | ||
| import java.util.function.Consumer; | ||
| import javax.annotation.Nullable; | ||
| import javax.annotation.concurrent.Immutable; | ||
|
|
||
| /** | ||
| * A gRPC response. | ||
| * | ||
| * @see GrpcSender#send(MessageWriter, Consumer, Consumer) | ||
| */ | ||
| @Immutable | ||
| public interface GrpcResponse { | ||
|
|
||
| /** The response gRPC status code. */ | ||
| GrpcStatusCode getStatusCode(); | ||
|
|
||
| /** A string description of the status. */ | ||
| @Nullable | ||
| String getStatusDescription(); | ||
|
|
||
| /** The gRPC response message bytes. */ | ||
| @SuppressWarnings("mutable") | ||
| byte[] getResponseMessage(); | ||
| } |
39 changes: 39 additions & 0 deletions
39
exporters/common/src/main/java/io/opentelemetry/exporter/grpc/GrpcSender.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.grpc; | ||
|
|
||
| import io.opentelemetry.exporter.marshal.MessageWriter; | ||
| import io.opentelemetry.sdk.common.CompletableResultCode; | ||
| import java.util.function.Consumer; | ||
|
|
||
| /** | ||
| * An abstraction for executing gRPC calls, allowing for implementations backed by different client | ||
| * libraries. | ||
| * | ||
| * <p>While this interface is public, implementing a custom sender is generally not recommended. The | ||
| * {@code opentelemetry-java} project provides built-in implementations that cover virtually all | ||
| * cases. | ||
| * | ||
| * @see GrpcSenderProvider | ||
| */ | ||
| public interface GrpcSender { | ||
|
|
||
| /** | ||
| * Execute a gRPC unary call, including any retry attempts. {@code onResponse} is called with the | ||
| * gRPC response, either a success response or an error response after retries. {@code onError} is | ||
| * called when the call could not be executed due to cancellation, connectivity problems, or | ||
| * timeout. | ||
| * | ||
| * @param messageWriter the message writer | ||
| * @param onResponse the callback to invoke with the gRPC response | ||
| * @param onError the callback to invoke when the gRPC call could not be executed | ||
| */ | ||
| void send( | ||
| MessageWriter messageWriter, Consumer<GrpcResponse> onResponse, Consumer<Throwable> onError); | ||
|
|
||
| /** Shutdown the sender. */ | ||
| CompletableResultCode shutdown(); | ||
| } |
92 changes: 92 additions & 0 deletions
92
exporters/common/src/main/java/io/opentelemetry/exporter/grpc/GrpcSenderConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.grpc; | ||
|
|
||
| import io.opentelemetry.exporter.compressor.Compressor; | ||
| import io.opentelemetry.exporter.marshal.MessageWriter; | ||
| import io.opentelemetry.sdk.common.export.RetryPolicy; | ||
| import java.io.OutputStream; | ||
| import java.net.URI; | ||
| import java.time.Duration; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Supplier; | ||
| import javax.annotation.Nullable; | ||
| import javax.annotation.concurrent.Immutable; | ||
| import javax.net.ssl.SSLContext; | ||
| import javax.net.ssl.X509TrustManager; | ||
|
|
||
| /** | ||
| * Configuration for {@link GrpcSender} implementations, provided via {@link | ||
| * GrpcSenderProvider#createSender(GrpcSenderConfig)}. | ||
| */ | ||
| @Immutable | ||
| public interface GrpcSenderConfig { | ||
|
|
||
| /** | ||
| * The gRPC endpoint to send to, including scheme. Omits path, which must be obtained from {@link | ||
| * #getFullMethodName()}. | ||
| */ | ||
| URI getEndpoint(); | ||
|
|
||
| /** | ||
| * The fully qualified gRPC method name, e.g. {@code | ||
| * opentelemetry.proto.collector.trace.v1.TraceService/Export}. | ||
| */ | ||
| String getFullMethodName(); | ||
|
|
||
| /** | ||
| * The compressor, or {@code null} if no compression is used. If present, {@link | ||
| * Compressor#compress(OutputStream)} must be applied to {@link | ||
| * MessageWriter#writeMessage(OutputStream)} when {@link GrpcSender#send(MessageWriter, Consumer, | ||
| * Consumer)} is called and {@link Compressor#getEncoding()} must be set as the {@code | ||
| * grpc-encoding}. | ||
| */ | ||
| @Nullable | ||
| Compressor getCompressor(); | ||
|
|
||
| /** | ||
| * The max duration allowed to send a request, including resolving DNS, connecting, writing the | ||
| * request, reading the response, and any retries via {@link #getRetryPolicy()}. | ||
| */ | ||
| Duration getTimeout(); | ||
|
|
||
| /** The max duration allowed to connect to a target host. */ | ||
| Duration getConnectTimeout(); | ||
|
|
||
| /** | ||
| * Additional headers that must be appended to every request. The resulting {@link Supplier} must | ||
| * be invoked for each request. | ||
| */ | ||
| Supplier<Map<String, List<String>>> getHeadersSupplier(); | ||
jack-berg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** The retry policy, or {@code null} if retry is disabled. */ | ||
| @Nullable | ||
| RetryPolicy getRetryPolicy(); | ||
|
|
||
| /** | ||
| * The SSL context to use, or {@code null} if the system default is used. If non-null, {@link | ||
| * #getTrustManager()} will also be non-null. | ||
| */ | ||
| @Nullable | ||
| SSLContext getSslContext(); | ||
jack-berg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * The trust manager to use, or {@code null} if the system default is used. If non-null, {@link | ||
| * #getSslContext()} will also be non-null. | ||
| */ | ||
| @Nullable | ||
| X509TrustManager getTrustManager(); | ||
jack-berg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * The executor service used to execute any asynchronous processing, or {@code null} if the sender | ||
| * default executor service should be used. | ||
| */ | ||
| @Nullable | ||
| ExecutorService getExecutorService(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
exporters/common/src/main/java/io/opentelemetry/exporter/grpc/GrpcStatusCode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.grpc; | ||
|
|
||
| /** | ||
| * gRPC status codes. See <a href="https://grpc.io/docs/guides/status-codes/">official grpc.io | ||
| * docs</a> for usage. | ||
| */ | ||
| public enum GrpcStatusCode { | ||
| OK(0), | ||
| CANCELLED(1), | ||
| UNKNOWN(2), | ||
| INVALID_ARGUMENT(3), | ||
| DEADLINE_EXCEEDED(4), | ||
| NOT_FOUND(5), | ||
| ALREADY_EXISTS(6), | ||
| PERMISSION_DENIED(7), | ||
| RESOURCE_EXHAUSTED(8), | ||
| FAILED_PRECONDITION(9), | ||
| ABORTED(10), | ||
| OUT_OF_RANGE(11), | ||
| UNIMPLEMENTED(12), | ||
| INTERNAL(13), | ||
| UNAVAILABLE(14), | ||
| DATA_LOSS(15), | ||
| UNAUTHENTICATED(16); | ||
|
|
||
| private final int value; | ||
|
|
||
| GrpcStatusCode(int value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| /** Returns the integer representation of the status code. */ | ||
| public int getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the {@link GrpcStatusCode} corresponding to the integer {@code value}, or {@link | ||
| * GrpcStatusCode#UNKNOWN} if the {@code value} is not recognized. | ||
| */ | ||
| public static GrpcStatusCode fromValue(int value) { | ||
| GrpcStatusCode[] values = GrpcStatusCode.values(); | ||
| if (value >= 0 && value < values.length) { | ||
| return values[value]; | ||
| } | ||
| return UNKNOWN; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.