Skip to content

Commit

Permalink
Export OTEL_TRACES_EXPORTER to meet new requirements of the Otel Ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrille-leclerc committed Nov 26, 2021
1 parent e656312 commit d3a89fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ public void setExportOtelConfigurationAsEnvironmentVariables(boolean exportOtelC

@Nonnull
public Map<String, String> getOtelConfigurationAsEnvironmentVariables() {
if (this.endpoint == null) {
return Collections.emptyMap();
}

Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.put(OTelEnvironmentVariablesConventions.OTEL_TRACES_EXPORTER, "otlp");
environmentVariables.put(OTelEnvironmentVariablesConventions.OTEL_EXPORTER_OTLP_ENDPOINT, this.endpoint);
String sanitizeOtlpEndpoint = sanitizeOtlpEndpoint(this.endpoint);
if (sanitizeOtlpEndpoint != null && sanitizeOtlpEndpoint.startsWith("http://")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class OTelEnvironmentVariablesConventions {
public static final String OTEL_EXPORTER_OTLP_ENDPOINT = "OTEL_EXPORTER_OTLP_ENDPOINT";
public static final String OTEL_EXPORTER_OTLP_INSECURE = "OTEL_EXPORTER_OTLP_INSECURE";
public static final String OTEL_EXPORTER_OTLP_TIMEOUT = "OTEL_EXPORTER_OTLP_TIMEOUT";
public static final String OTEL_TRACES_EXPORTER = "OTEL_TRACES_EXPORTER";

public static final String SPAN_ID = "SPAN_ID";
public static final String TRACE_ID = "TRACE_ID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ protected void assertEnvironmentVariables(EnvVars environment) {
MatcherAssert.assertThat(environment.get(OTelEnvironmentVariablesConventions.SPAN_ID), CoreMatchers.is(CoreMatchers.notNullValue()));
MatcherAssert.assertThat(environment.get(OTelEnvironmentVariablesConventions.TRACE_ID), CoreMatchers.is(CoreMatchers.notNullValue()));
// See src/test/resources/io/jenkins/plugins/opentelemetry/jcasc-elastic-backend.yml
MatcherAssert.assertThat(environment.get(OTelEnvironmentVariablesConventions.OTEL_TRACES_EXPORTER), CoreMatchers.is("otlp"));
MatcherAssert.assertThat(environment.get(OTelEnvironmentVariablesConventions.OTEL_EXPORTER_OTLP_ENDPOINT), CoreMatchers.is("http://otel-collector-contrib:4317"));
MatcherAssert.assertThat(environment.get(OTelEnvironmentVariablesConventions.OTEL_EXPORTER_OTLP_INSECURE), CoreMatchers.is("true"));
MatcherAssert.assertThat(environment.get(OTelEnvironmentVariablesConventions.OTEL_EXPORTER_OTLP_TIMEOUT), CoreMatchers.is("3000"));
Expand Down

0 comments on commit d3a89fd

Please sign in to comment.