Skip to content
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

Fix OTel exporter headers config #32073

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions docs/src/main/asciidoc/opentelemetry.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private static Map<String, String> relocations() {
"quarkus.otel.traces.suppress-non-application-uris");
relocations.put("quarkus.opentelemetry.tracer.include-static-resources",
"quarkus.otel.traces.include-static-resources");
relocations.put("quarkus.opentelemetry.tracer.exporter.otlp.headers",
"quarkus.otel.exporter.otlp.traces.headers");
return Collections.unmodifiableMap(relocations);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<byte[]> 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<ClientTlsConfig> client;

/**
* Add header to request. Optional.
*/
@ConfigItem()
public Map<String, String> headers;

/**
* Sets the method used to compress payloads. If unset, compression is disabled. Currently
* supported compression methods include "gzip" and "none".
*/
@ConfigItem()
public Optional<OtelConnectionRuntimeConfig.CompressionType> 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<String> protocol;

// @ConfigGroup
// public class ClientTlsConfig {
//
// /**
// * Key
// */
// @ConfigItem()
// public byte[] key;
//
// /**
// * Certificate
// */
// @ConfigItem()
// public byte[] certificate;
// }
// TODO additional global exporter configuration

/**
* From <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ public class OtlpExporterTracesConfig extends OtelConnectionRuntimeConfig {
/**
* Key-value pairs to be used as headers associated with gRPC requests.
* The format is similar to the {@code OTEL_EXPORTER_OTLP_HEADERS} environment variable,
* a list of key-value pairs separated by the "=" character.
* See <a href=
* "https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables">
* Specifying headers</a> 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<String, String> headers;

/**
Expand Down