-
Notifications
You must be signed in to change notification settings - Fork 1k
Implement otlp exporter providers #5003
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
Merged
jack-berg
merged 5 commits into
open-telemetry:main
from
jack-berg:otlp-exporter-provider
Dec 18, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1b7588d
Implement otlp exporter providers
jack-berg d71be6b
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 8f63af0
Remove redundant else
jack-berg a3ec138
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 459dfe7
Restore unsupported protocol test
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
There are no files selected for viewing
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
82 changes: 82 additions & 0 deletions
82
...all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpMetricExporterProvider.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,82 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.otlp.internal; | ||
|
|
||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_METRICS; | ||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC; | ||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF; | ||
|
|
||
| import io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil; | ||
| import io.opentelemetry.exporter.internal.retry.RetryUtil; | ||
| import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter; | ||
| import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder; | ||
| import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter; | ||
| import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider; | ||
| import io.opentelemetry.sdk.metrics.export.MetricExporter; | ||
|
|
||
| /** | ||
| * {@link MetricExporter} SPI implementation for {@link OtlpGrpcMetricExporter} and {@link | ||
| * OtlpHttpMetricExporter}. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public class OtlpMetricExporterProvider implements ConfigurableMetricExporterProvider { | ||
| @Override | ||
| public MetricExporter createExporter(ConfigProperties config) { | ||
| String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_METRICS, config); | ||
|
|
||
| if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) { | ||
| OtlpHttpMetricExporterBuilder builder = OtlpHttpMetricExporter.builder(); | ||
|
|
||
| OtlpConfigUtil.configureOtlpExporterBuilder( | ||
| DATA_TYPE_METRICS, | ||
| config, | ||
| builder::setEndpoint, | ||
| builder::addHeader, | ||
| builder::setCompression, | ||
| builder::setTimeout, | ||
| builder::setTrustedCertificates, | ||
| builder::setClientTls, | ||
| retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy)); | ||
| OtlpConfigUtil.configureOtlpAggregationTemporality( | ||
| config, builder::setAggregationTemporalitySelector); | ||
| OtlpConfigUtil.configureOtlpHistogramDefaultAggregation( | ||
| config, builder::setDefaultAggregationSelector); | ||
|
|
||
| return builder.build(); | ||
| } else if (protocol.equals(PROTOCOL_GRPC)) { | ||
| OtlpGrpcMetricExporterBuilder builder = OtlpGrpcMetricExporter.builder(); | ||
|
|
||
| OtlpConfigUtil.configureOtlpExporterBuilder( | ||
| DATA_TYPE_METRICS, | ||
| config, | ||
| builder::setEndpoint, | ||
| builder::addHeader, | ||
| builder::setCompression, | ||
| builder::setTimeout, | ||
| builder::setTrustedCertificates, | ||
| builder::setClientTls, | ||
| retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy)); | ||
| OtlpConfigUtil.configureOtlpAggregationTemporality( | ||
| config, builder::setAggregationTemporalitySelector); | ||
| OtlpConfigUtil.configureOtlpHistogramDefaultAggregation( | ||
| config, builder::setDefaultAggregationSelector); | ||
|
|
||
| return builder.build(); | ||
| } else { | ||
| throw new ConfigurationException("Unsupported OTLP metrics protocol: " + protocol); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "otlp"; | ||
| } | ||
| } | ||
73 changes: 73 additions & 0 deletions
73
...p/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpSpanExporterProvider.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,73 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.otlp.internal; | ||
|
|
||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_TRACES; | ||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC; | ||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF; | ||
|
|
||
| import io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil; | ||
| import io.opentelemetry.exporter.internal.retry.RetryUtil; | ||
| import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter; | ||
| import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder; | ||
| import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; | ||
| import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider; | ||
| import io.opentelemetry.sdk.trace.export.SpanExporter; | ||
|
|
||
| /** | ||
| * {@link SpanExporter} SPI implementation for {@link OtlpGrpcSpanExporter} and {@link | ||
| * OtlpHttpSpanExporter}. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public class OtlpSpanExporterProvider implements ConfigurableSpanExporterProvider { | ||
| @Override | ||
| public SpanExporter createExporter(ConfigProperties config) { | ||
| String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_TRACES, config); | ||
| if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) { | ||
| OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder(); | ||
|
|
||
| OtlpConfigUtil.configureOtlpExporterBuilder( | ||
| DATA_TYPE_TRACES, | ||
| config, | ||
| builder::setEndpoint, | ||
| builder::addHeader, | ||
| builder::setCompression, | ||
| builder::setTimeout, | ||
| builder::setTrustedCertificates, | ||
| builder::setClientTls, | ||
| retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy)); | ||
|
|
||
| return builder.build(); | ||
| } else if (protocol.equals(PROTOCOL_GRPC)) { | ||
| OtlpGrpcSpanExporterBuilder builder = OtlpGrpcSpanExporter.builder(); | ||
|
|
||
| OtlpConfigUtil.configureOtlpExporterBuilder( | ||
| DATA_TYPE_TRACES, | ||
| config, | ||
| builder::setEndpoint, | ||
| builder::addHeader, | ||
| builder::setCompression, | ||
| builder::setTimeout, | ||
| builder::setTrustedCertificates, | ||
| builder::setClientTls, | ||
| retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy)); | ||
|
|
||
| return builder.build(); | ||
| } else { | ||
|
jack-berg marked this conversation as resolved.
Outdated
|
||
| throw new ConfigurationException("Unsupported OTLP traces protocol: " + protocol); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "otlp"; | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
...ervices/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider
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 @@ | ||
| io.opentelemetry.exporter.otlp.internal.OtlpMetricExporterProvider |
1 change: 1 addition & 0 deletions
1
...F/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider
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 @@ | ||
| io.opentelemetry.exporter.otlp.internal.OtlpSpanExporterProvider |
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
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
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
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
74 changes: 74 additions & 0 deletions
74
.../src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpLogRecordExporterProvider.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,74 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.otlp.internal; | ||
|
|
||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_LOGS; | ||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC; | ||
| import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF; | ||
|
|
||
| import io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil; | ||
| import io.opentelemetry.exporter.internal.retry.RetryUtil; | ||
| import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter; | ||
| import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder; | ||
| import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter; | ||
| import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider; | ||
| import io.opentelemetry.sdk.logs.export.LogRecordExporter; | ||
|
|
||
| /** | ||
| * {@link LogRecordExporter} SPI implementation for {@link OtlpGrpcLogRecordExporter} and {@link | ||
| * OtlpHttpLogRecordExporter}. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public class OtlpLogRecordExporterProvider implements ConfigurableLogRecordExporterProvider { | ||
| @Override | ||
| public LogRecordExporter createExporter(ConfigProperties config) { | ||
| String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_LOGS, config); | ||
|
|
||
| if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) { | ||
| OtlpHttpLogRecordExporterBuilder builder = OtlpHttpLogRecordExporter.builder(); | ||
|
|
||
| OtlpConfigUtil.configureOtlpExporterBuilder( | ||
| DATA_TYPE_LOGS, | ||
| config, | ||
| builder::setEndpoint, | ||
| builder::addHeader, | ||
| builder::setCompression, | ||
| builder::setTimeout, | ||
| builder::setTrustedCertificates, | ||
| builder::setClientTls, | ||
| retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy)); | ||
|
|
||
| return builder.build(); | ||
| } else if (protocol.equals(PROTOCOL_GRPC)) { | ||
| OtlpGrpcLogRecordExporterBuilder builder = OtlpGrpcLogRecordExporter.builder(); | ||
|
|
||
| OtlpConfigUtil.configureOtlpExporterBuilder( | ||
| DATA_TYPE_LOGS, | ||
| config, | ||
| builder::setEndpoint, | ||
| builder::addHeader, | ||
| builder::setCompression, | ||
| builder::setTimeout, | ||
| builder::setTrustedCertificates, | ||
| builder::setClientTls, | ||
| retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy)); | ||
|
|
||
| return builder.build(); | ||
| } else { | ||
| throw new ConfigurationException("Unsupported OTLP logs protocol: " + protocol); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "otlp"; | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
...ervices/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider
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 @@ | ||
| io.opentelemetry.exporter.otlp.internal.OtlpLogRecordExporterProvider |
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.