-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement otlp exporter providers (#5003)
* Implement otlp exporter providers * Remove redundant else * Restore unsupported protocol test
- Loading branch information
Showing
30 changed files
with
607 additions
and
556 deletions.
There are no files selected for viewing
This file contains 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
81 changes: 81 additions & 0 deletions
81
...all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpMetricExporterProvider.java
This file contains 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,81 @@ | ||
/* | ||
* 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(); | ||
} | ||
throw new ConfigurationException("Unsupported OTLP metrics protocol: " + protocol); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "otlp"; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...p/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpSpanExporterProvider.java
This file contains 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,72 @@ | ||
/* | ||
* 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(); | ||
} | ||
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 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 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 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 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 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 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
73 changes: 73 additions & 0 deletions
73
.../src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpLogRecordExporterProvider.java
This file contains 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_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(); | ||
} | ||
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 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.