|
1 | 1 | package io.quarkus.opentelemetry.runtime.exporter.otlp;
|
2 | 2 |
|
3 |
| -import static io.quarkus.opentelemetry.runtime.OpenTelemetryUtil.convertKeyValueListToMap; |
4 | 3 | import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterRuntimeConfig.DEFAULT_GRPC_BASE_URI;
|
5 | 4 | import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterTracesConfig.Protocol.HTTP_PROTOBUF;
|
6 | 5 |
|
7 | 6 | import java.util.List;
|
8 |
| -import java.util.Map; |
9 |
| -import java.util.function.Consumer; |
10 | 7 |
|
11 | 8 | import jakarta.enterprise.inject.Any;
|
12 | 9 | import jakarta.enterprise.inject.spi.CDI;
|
|
17 | 14 | import io.opentelemetry.sdk.trace.export.BatchSpanProcessorBuilder;
|
18 | 15 | import io.opentelemetry.sdk.trace.export.SpanExporter;
|
19 | 16 | import io.quarkus.opentelemetry.runtime.config.runtime.OTelRuntimeConfig;
|
20 |
| -import io.quarkus.opentelemetry.runtime.config.runtime.exporter.CompressionType; |
21 | 17 | import io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterRuntimeConfig;
|
22 | 18 | import io.quarkus.runtime.LaunchMode;
|
23 | 19 | import io.quarkus.runtime.annotations.Recorder;
|
@@ -88,28 +84,33 @@ private OtlpGrpcSpanExporter createOtlpGrpcSpanExporter(OtlpExporterRuntimeConfi
|
88 | 84 | // FIXME TLS Support. Was not available before but will be available soon.
|
89 | 85 | // exporterRuntimeConfig.traces.certificate.ifPresent(exporterBuilder::setTrustedCertificates);
|
90 | 86 | // exporterRuntimeConfig.client.ifPresent(exporterBuilder::setClientTls);
|
91 |
| - exporterRuntimeConfig.traces().headers().ifPresent(new Consumer<List<String>>() { |
92 |
| - @Override |
93 |
| - public void accept(final List<String> headers) { |
94 |
| - for (Map.Entry<String, String> entry : convertKeyValueListToMap(headers).entrySet()) { |
95 |
| - String key = entry.getKey(); |
96 |
| - String value = entry.getValue(); |
| 87 | + |
| 88 | + if (exporterRuntimeConfig.traces().headers().isPresent()) { |
| 89 | + List<String> headers = exporterRuntimeConfig.traces().headers().get(); |
| 90 | + if (!headers.isEmpty()) { |
| 91 | + for (String header : headers) { |
| 92 | + if (header.isEmpty()) { |
| 93 | + continue; |
| 94 | + } |
| 95 | + String[] parts = header.split("=", 2); |
| 96 | + String key = parts[0].trim(); |
| 97 | + String value = parts[1].trim(); |
97 | 98 | exporterBuilder.addHeader(key, value);
|
98 | 99 | }
|
99 | 100 | }
|
100 |
| - }); |
101 |
| - exporterRuntimeConfig.traces().compression() |
102 |
| - .ifPresent(new Consumer<CompressionType>() { |
103 |
| - @Override |
104 |
| - public void accept(CompressionType compression) { |
105 |
| - exporterBuilder.setCompression(compression.getValue()); |
106 |
| - } |
107 |
| - }); |
| 101 | + } |
108 | 102 |
|
109 |
| - if (!exporterRuntimeConfig.traces().protocol().orElse("").equals(HTTP_PROTOBUF)) { |
110 |
| - throw new IllegalStateException("Only the GRPC Exporter is currently supported. " + |
111 |
| - "Please check `otel.exporter.otlp.traces.protocol` property"); |
| 103 | + if (exporterRuntimeConfig.traces().compression().isPresent()) { |
| 104 | + exporterBuilder.setCompression(exporterRuntimeConfig.traces().compression().get().getValue()); |
112 | 105 | }
|
| 106 | + |
| 107 | + if (exporterRuntimeConfig.traces().protocol().isPresent()) { |
| 108 | + if (!exporterRuntimeConfig.traces().protocol().get().equals(HTTP_PROTOBUF)) { |
| 109 | + throw new IllegalStateException("Only the GRPC Exporter is currently supported. " + |
| 110 | + "Please check `quarkus.otel.exporter.otlp.traces.protocol` property"); |
| 111 | + } |
| 112 | + } |
| 113 | + |
113 | 114 | return exporterBuilder.build();
|
114 | 115 | }
|
115 | 116 | }
|
0 commit comments