Skip to content

Commit 9e3f702

Browse files
authored
Declarative config 0.4 (#7064)
1 parent 04677f9 commit 9e3f702

File tree

85 files changed

+2752
-1264
lines changed

Some content is hidden

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

85 files changed

+2752
-1264
lines changed

exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/logs/OtlpStdoutLogRecordExporterComponentProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Class<LogRecordExporter> getType() {
2626

2727
@Override
2828
public String getName() {
29-
return "experimental-otlp/stdout";
29+
return "otlp_file/development";
3030
}
3131

3232
@Override

exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/metrics/OtlpStdoutMetricExporterComponentProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Class<MetricExporter> getType() {
2626

2727
@Override
2828
public String getName() {
29-
return "experimental-otlp/stdout";
29+
return "otlp_file/development";
3030
}
3131

3232
@Override

exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/traces/OtlpStdoutSpanExporterComponentProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Class<SpanExporter> getType() {
2626

2727
@Override
2828
public String getName() {
29-
return "experimental-otlp/stdout";
29+
return "otlp_file/development";
3030
}
3131

3232
@Override

exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/AbstractOtlpStdoutExporterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ protected T exporterFromComponentProvider(DeclarativeConfigProperties properties
335335
.filter(
336336
p -> {
337337
ComponentProvider<?> c = (ComponentProvider<?>) p;
338-
return "experimental-otlp/stdout".equals(c.getName())
338+
return "otlp_file/development".equals(c.getName())
339339
&& c.getType().equals(componentProviderType);
340340
})
341341
.findFirst()

exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpDeclarativeConfigUtil.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ public static void configureOtlpExporterBuilder(
5454
Consumer<byte[]> setTrustedCertificates,
5555
BiConsumer<byte[], byte[]> setClientTls,
5656
Consumer<RetryPolicy> setRetryPolicy,
57-
Consumer<MemoryMode> setMemoryMode) {
58-
String protocol = getStructuredConfigOtlpProtocol(config);
59-
boolean isHttpProtobuf = protocol.equals(PROTOCOL_HTTP_PROTOBUF);
57+
Consumer<MemoryMode> setMemoryMode,
58+
boolean isHttpProtobuf) {
6059
URL endpoint = validateEndpoint(config.getString("endpoint"), isHttpProtobuf);
6160
if (endpoint != null) {
6261
setEndpoint.accept(endpoint.toString());
@@ -92,16 +91,16 @@ public static void configureOtlpExporterBuilder(
9291
setTimeout.accept(Duration.ofMillis(timeoutMs));
9392
}
9493

95-
String certificatePath = config.getString("certificate");
96-
String clientKeyPath = config.getString("client_key");
97-
String clientKeyChainPath = config.getString("client_certificate");
94+
String certificatePath = config.getString("certificate_file");
95+
String clientKeyPath = config.getString("client_key_file");
96+
String clientKeyChainPath = config.getString("client_certificate_file");
9897

9998
if (clientKeyPath != null && clientKeyChainPath == null) {
10099
throw new ConfigurationException(
101-
"client_key provided without client_certificate - both client_key and client_certificate must be set");
100+
"client_key_file provided without client_certificate_file - both client_key_file and client_certificate_file must be set");
102101
} else if (clientKeyPath == null && clientKeyChainPath != null) {
103102
throw new ConfigurationException(
104-
"client_certificate provided without client_key - both client_key and client_certificate must be set");
103+
"client_certificate_file provided without client_key_file - both client_key_file and client_certificate_file must be set");
105104
}
106105
byte[] certificateBytes = readFileBytes(certificatePath);
107106
if (certificateBytes != null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.otlp.internal;
7+
8+
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.DATA_TYPE_LOGS;
9+
10+
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
11+
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
12+
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder;
13+
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
14+
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
15+
16+
/**
17+
* Declarative configuration SPI implementation for {@link OtlpGrpcLogRecordExporter}.
18+
*
19+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
20+
* at any time.
21+
*/
22+
public class OtlpGrpcLogRecordExporterComponentProvider
23+
implements ComponentProvider<LogRecordExporter> {
24+
25+
@Override
26+
public Class<LogRecordExporter> getType() {
27+
return LogRecordExporter.class;
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return "otlp_grpc";
33+
}
34+
35+
@Override
36+
public LogRecordExporter create(DeclarativeConfigProperties config) {
37+
OtlpGrpcLogRecordExporterBuilder builder = grpcBuilder();
38+
39+
OtlpDeclarativeConfigUtil.configureOtlpExporterBuilder(
40+
DATA_TYPE_LOGS,
41+
config,
42+
builder::setEndpoint,
43+
builder::addHeader,
44+
builder::setCompression,
45+
builder::setTimeout,
46+
builder::setTrustedCertificates,
47+
builder::setClientTls,
48+
builder::setRetryPolicy,
49+
builder::setMemoryMode,
50+
/* isHttpProtobuf= */ false);
51+
52+
return builder.build();
53+
}
54+
55+
// Visible for testing
56+
OtlpGrpcLogRecordExporterBuilder grpcBuilder() {
57+
return OtlpGrpcLogRecordExporter.builder();
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.otlp.internal;
7+
8+
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.DATA_TYPE_METRICS;
9+
10+
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
11+
import io.opentelemetry.exporter.internal.IncubatingExporterBuilderUtil;
12+
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
13+
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder;
14+
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
15+
import io.opentelemetry.sdk.metrics.export.MetricExporter;
16+
17+
/**
18+
* Declarative configuration SPI implementation for {@link OtlpGrpcMetricExporter}.
19+
*
20+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
21+
* at any time.
22+
*/
23+
public class OtlpGrpcMetricExporterComponentProvider implements ComponentProvider<MetricExporter> {
24+
25+
@Override
26+
public Class<MetricExporter> getType() {
27+
return MetricExporter.class;
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return "otlp_grpc";
33+
}
34+
35+
@Override
36+
public MetricExporter create(DeclarativeConfigProperties config) {
37+
OtlpGrpcMetricExporterBuilder builder = grpcBuilder();
38+
39+
OtlpDeclarativeConfigUtil.configureOtlpExporterBuilder(
40+
DATA_TYPE_METRICS,
41+
config,
42+
builder::setEndpoint,
43+
builder::addHeader,
44+
builder::setCompression,
45+
builder::setTimeout,
46+
builder::setTrustedCertificates,
47+
builder::setClientTls,
48+
builder::setRetryPolicy,
49+
builder::setMemoryMode,
50+
/* isHttpProtobuf= */ false);
51+
IncubatingExporterBuilderUtil.configureOtlpAggregationTemporality(
52+
config, builder::setAggregationTemporalitySelector);
53+
IncubatingExporterBuilderUtil.configureOtlpHistogramDefaultAggregation(
54+
config, builder::setDefaultAggregationSelector);
55+
56+
return builder.build();
57+
}
58+
59+
// Visible for testing
60+
OtlpGrpcMetricExporterBuilder grpcBuilder() {
61+
return OtlpGrpcMetricExporter.builder();
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.otlp.internal;
7+
8+
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.DATA_TYPE_TRACES;
9+
10+
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
11+
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
12+
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
13+
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
14+
import io.opentelemetry.sdk.trace.export.SpanExporter;
15+
16+
/**
17+
* Declarative configuration SPI implementation for {@link OtlpGrpcSpanExporter}.
18+
*
19+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
20+
* at any time.
21+
*/
22+
public class OtlpGrpcSpanExporterComponentProvider implements ComponentProvider<SpanExporter> {
23+
24+
@Override
25+
public Class<SpanExporter> getType() {
26+
return SpanExporter.class;
27+
}
28+
29+
@Override
30+
public String getName() {
31+
return "otlp_grpc";
32+
}
33+
34+
@Override
35+
public SpanExporter create(DeclarativeConfigProperties config) {
36+
OtlpGrpcSpanExporterBuilder builder = grpcBuilder();
37+
38+
OtlpDeclarativeConfigUtil.configureOtlpExporterBuilder(
39+
DATA_TYPE_TRACES,
40+
config,
41+
builder::setEndpoint,
42+
builder::addHeader,
43+
builder::setCompression,
44+
builder::setTimeout,
45+
builder::setTrustedCertificates,
46+
builder::setClientTls,
47+
builder::setRetryPolicy,
48+
builder::setMemoryMode,
49+
/* isHttpProtobuf= */ false);
50+
51+
return builder.build();
52+
}
53+
54+
// Visible for testing
55+
OtlpGrpcSpanExporterBuilder grpcBuilder() {
56+
return OtlpGrpcSpanExporter.builder();
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.otlp.internal;
7+
8+
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.DATA_TYPE_LOGS;
9+
10+
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
11+
import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter;
12+
import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder;
13+
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
14+
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
15+
16+
/**
17+
* Declarative configuration SPI implementation for {@link OtlpHttpLogRecordExporter}.
18+
*
19+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
20+
* at any time.
21+
*/
22+
public class OtlpHttpLogRecordExporterComponentProvider
23+
implements ComponentProvider<LogRecordExporter> {
24+
25+
@Override
26+
public Class<LogRecordExporter> getType() {
27+
return LogRecordExporter.class;
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return "otlp_http";
33+
}
34+
35+
@Override
36+
public LogRecordExporter create(DeclarativeConfigProperties config) {
37+
OtlpHttpLogRecordExporterBuilder builder = httpBuilder();
38+
39+
OtlpDeclarativeConfigUtil.configureOtlpExporterBuilder(
40+
DATA_TYPE_LOGS,
41+
config,
42+
builder::setEndpoint,
43+
builder::addHeader,
44+
builder::setCompression,
45+
builder::setTimeout,
46+
builder::setTrustedCertificates,
47+
builder::setClientTls,
48+
builder::setRetryPolicy,
49+
builder::setMemoryMode,
50+
/* isHttpProtobuf= */ true);
51+
52+
return builder.build();
53+
}
54+
55+
// Visible for testing
56+
OtlpHttpLogRecordExporterBuilder httpBuilder() {
57+
return OtlpHttpLogRecordExporter.builder();
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.exporter.otlp.internal;
7+
8+
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.DATA_TYPE_METRICS;
9+
10+
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
11+
import io.opentelemetry.exporter.internal.IncubatingExporterBuilderUtil;
12+
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter;
13+
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder;
14+
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
15+
import io.opentelemetry.sdk.metrics.export.MetricExporter;
16+
17+
/**
18+
* Declarative configuration SPI implementation for {@link OtlpHttpMetricExporter}.
19+
*
20+
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
21+
* at any time.
22+
*/
23+
public class OtlpHttpMetricExporterComponentProvider implements ComponentProvider<MetricExporter> {
24+
25+
@Override
26+
public Class<MetricExporter> getType() {
27+
return MetricExporter.class;
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return "otlp_http";
33+
}
34+
35+
@Override
36+
public MetricExporter create(DeclarativeConfigProperties config) {
37+
OtlpHttpMetricExporterBuilder builder = httpBuilder();
38+
39+
OtlpDeclarativeConfigUtil.configureOtlpExporterBuilder(
40+
DATA_TYPE_METRICS,
41+
config,
42+
builder::setEndpoint,
43+
builder::addHeader,
44+
builder::setCompression,
45+
builder::setTimeout,
46+
builder::setTrustedCertificates,
47+
builder::setClientTls,
48+
builder::setRetryPolicy,
49+
builder::setMemoryMode,
50+
/* isHttpProtobuf= */ true);
51+
IncubatingExporterBuilderUtil.configureOtlpAggregationTemporality(
52+
config, builder::setAggregationTemporalitySelector);
53+
IncubatingExporterBuilderUtil.configureOtlpHistogramDefaultAggregation(
54+
config, builder::setDefaultAggregationSelector);
55+
56+
return builder.build();
57+
}
58+
59+
// Visible for testing
60+
OtlpHttpMetricExporterBuilder httpBuilder() {
61+
return OtlpHttpMetricExporter.builder();
62+
}
63+
}

0 commit comments

Comments
 (0)