From d3eedcc4593804f4113ea9f466d59fc7e98b2fe6 Mon Sep 17 00:00:00 2001 From: brunobat Date: Thu, 23 Mar 2023 13:33:06 +0000 Subject: [PATCH] Fix OTel exporter headers config --- docs/src/main/asciidoc/opentelemetry.adoc | 14 +++-- .../exporter/OtlpExporterRuntimeConfig.java | 61 +------------------ .../exporter/OtlpExporterTracesConfig.java | 6 +- 3 files changed, 12 insertions(+), 69 deletions(-) diff --git a/docs/src/main/asciidoc/opentelemetry.adoc b/docs/src/main/asciidoc/opentelemetry.adoc index 41160b625ddd04..96c7913e20c024 100644 --- a/docs/src/main/asciidoc/opentelemetry.adoc +++ b/docs/src/main/asciidoc/opentelemetry.adoc @@ -108,22 +108,26 @@ endpoint will be traced without any required code changes. === Create the configuration -There are no mandatory configurations for the extension to work. If you need to change any of the default property values, here is an example on how to configure the default OTLP gRPC Exporter within the application, using the `src/main/resources/application.properties` file: +There are no mandatory configurations for the extension to work. + +If you need to change any of the default property values, here is an example on how to configure the default OTLP gRPC Exporter within the application, using the `src/main/resources/application.properties` file: [source,properties] ---- quarkus.application.name=myservice // <1> quarkus.otel.exporter.otlp.traces.endpoint=http://localhost:4317 // <2> -quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n // <3> +quarkus.otel.exporter.otlp.traces.headers=authorization=Bearer my_secret // <3> +quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n // <4> # Alternative to the console log -quarkus.http.access-log.pattern="...traceId=%{X,traceId} spanId=%{X,spanId}" // <4> +quarkus.http.access-log.pattern="...traceId=%{X,traceId} spanId=%{X,spanId}" // <5> ---- <1> All spans created from the application will include an OpenTelemetry `Resource` indicating the span was created by the `myservice` application. If not set, it will default to the artifact id. <2> gRPC endpoint to send spans. If not set, it will default to `http://localhost:4317`. -<3> Add tracing information into log messages. -<4> You can also only put the trace info into the access log. In this case you must omit the info in the console log format. +<3> Optional gRPC headers commonly used for authentication +<4> Add tracing information into log messages. +<5> You can also only put the trace info into the access log. In this case you must omit the info in the console log format. [NOTE] ==== diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterRuntimeConfig.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterRuntimeConfig.java index 6e73be04ee2d85..40cfa6a280a918 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterRuntimeConfig.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterRuntimeConfig.java @@ -1,7 +1,5 @@ package io.quarkus.opentelemetry.runtime.config.runtime.exporter; -import java.time.Duration; -import java.util.Map; import java.util.Optional; import io.quarkus.runtime.annotations.ConfigItem; @@ -25,64 +23,7 @@ public class OtlpExporterRuntimeConfig { public OtlpExporterTracesConfig traces; // TODO metrics(); // TODO logs(); - - // /** - // * Sets the certificate chain to use for verifying servers when TLS is enabled. The {@code byte[]} - // * should contain an X.509 certificate collection in PEM format. If not set, TLS connections will - // * use the system default trusted certificates. - // */ - // @ConfigItem() - // public Optional certificate; - - // /** - // * Sets ths client key and the certificate chain to use for verifying client when TLS is enabled. - // * The key must be PKCS8, and both must be in PEM format. - // */ - // @ConfigItem() - // public Optional client; - - /** - * Add header to request. Optional. - */ - @ConfigItem() - public Map headers; - - /** - * Sets the method used to compress payloads. If unset, compression is disabled. Currently - * supported compression methods include "gzip" and "none". - */ - @ConfigItem() - public Optional compression; - - /** - * Sets the maximum time to wait for the collector to process an exported batch of spans. If - * unset, defaults to {@value OtelConnectionRuntimeConfig.Constants#DEFAULT_TIMEOUT_SECS}s. - */ - @ConfigItem(defaultValue = OtelConnectionRuntimeConfig.Constants.DEFAULT_TIMEOUT_SECS) - public Duration timeout; - - /** - * OTLP defines the encoding of telemetry data and the protocol used to exchange data between the client and the server. - * Depending on the exporter, the available protocols will be different. - */ - @ConfigItem() - public Optional protocol; - - // @ConfigGroup - // public class ClientTlsConfig { - // - // /** - // * Key - // */ - // @ConfigItem() - // public byte[] key; - // - // /** - // * Certificate - // */ - // @ConfigItem() - // public byte[] certificate; - // } + // TODO additional global exporter configuration /** * From - * Specifying headers for more details. + * a list of key-value pairs separated by the "=" character. i.e.: key1=value1,key2=value2 */ + @ConfigItem(defaultValue = "${quarkus.opentelemetry.tracer.exporter.otlp.headers}") public Map headers; /**