Initial Propagators support.
MODIFY
agent-bootstrap/src/main/java/io/opentelemetry/auto/config/Config.java
agent-bootstrap/src/main/java/io/opentelemetry/auto/config/Config.java
@@ -56,6 +56,7 @@ public class Config {
public static final String EXPORTER_JAR = "exporter.jar";
public static final String SERVICE = "service";
+ public static final String PROPAGATORS = "propagators";
public static final String CONFIGURATION_FILE = "trace.config";
public static final String TRACE_ENABLED = "trace.enabled";
public static final String INTEGRATIONS_ENABLED = "integrations.enabled";
@@ -104,6 +105,7 @@ public class Config {
@Getter private final String exporterJar;
@Getter private final String serviceName;
+ @Getter private final List<String> propagators;
@Getter private final boolean traceEnabled;
@Getter private final boolean integrationsEnabled;
@Getter private final List<String> excludedClasses;
@@ -150,6 +152,7 @@ public class Config {
Config() {
propertiesFromConfigFile = loadConfigurationFile();
+ propagators = getListSettingFromEnvironment(PROPAGATORS, null);
exporterJar = getSettingFromEnvironment(EXPORTER_JAR, null);
serviceName = getSettingFromEnvironment(SERVICE, "(unknown)");
traceEnabled = getBooleanSettingFromEnvironment(TRACE_ENABLED, DEFAULT_TRACE_ENABLED);
@@ -211,6 +214,8 @@ public class Config {
exporterJar = properties.getProperty(EXPORTER_JAR, parent.exporterJar);
serviceName = properties.getProperty(SERVICE, parent.serviceName);
+ propagators = getPropertyListValue(properties, PROPAGATORS, parent.propagators);
+
traceEnabled = getPropertyBooleanValue(properties, TRACE_ENABLED, parent.traceEnabled);
integrationsEnabled =
getPropertyBooleanValue(properties, INTEGRATIONS_ENABLED, parent.integrationsEnabled);

MODIFY
agent-tooling/agent-tooling.gradle
agent-tooling/agent-tooling.gradle
@@ -19,6 +19,7 @@ dependencies {
compile deps.opentelemetryApi
compile deps.opentelemetrySdk
compile deps.opentelemetrySdkAutoConfig
+ compile deps.opentelemetryTraceProps
// TODO: move the interface in exporter-support into opentelemetry-sdk-contrib-auto-config
compile project(':exporter-support')

ADD
agent-tooling/src/main/java/io/opentelemetry/auto/tooling/PropagatorsInitializer.java
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.opentelemetry.auto.tooling;
+
+import com.google.common.collect.ImmutableMap;
+import io.opentelemetry.OpenTelemetry;
+import io.opentelemetry.context.propagation.DefaultContextPropagators;
+import io.opentelemetry.context.propagation.HttpTextFormat;
+import io.opentelemetry.contrib.trace.propagation.B3Propagator;
+import io.opentelemetry.trace.propagation.HttpTraceContext;
+import java.util.List;
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class PropagatorsInitializer {
+ private static final String TRACE_CONTEXT = "tracecontext";
+ private static final String B3 = "b3";
+
+ private static final Map<String, HttpTextFormat> TEXTMAP_PROPAGATORS =
+ ImmutableMap.of(
+ TRACE_CONTEXT, new HttpTraceContext(),
+ B3, new B3Propagator());
+
+ /** Initialize OpenTelemetry global Propagators with propagator list, if any. */
+ public static void initializePropagators(List<String> propagators) {
+ /* Only override the default propagators *if* the user specified any. */
+ if (propagators.size() == 0) {
+ return;
+ }
+
+ DefaultContextPropagators.Builder propagatorsBuilder = DefaultContextPropagators.builder();
+
+ for (String propagatorId : propagators) {
+ HttpTextFormat textPropagator = TEXTMAP_PROPAGATORS.get(propagatorId.trim().toLowerCase());
+ if (textPropagator != null) {
+ propagatorsBuilder.addHttpTextFormat(textPropagator);
+ log.info("Added " + textPropagator + " propagator");
+ } else {
+ log.warn("No matching propagator for " + propagatorId);
+ }
+ }
+
+ OpenTelemetry.setPropagators(propagatorsBuilder.build());
+ }
+}

MODIFY
agent-tooling/src/main/java/io/opentelemetry/auto/tooling/TracerInstaller.java
agent-tooling/src/main/java/io/opentelemetry/auto/tooling/TracerInstaller.java
@@ -48,6 +48,8 @@ public class TracerInstaller {
} else {
log.info("Tracing is disabled.");
}
+
+ PropagatorsInitializer.initializePropagators(Config.get().getPropagators());
}
@VisibleForTesting

MODIFY
gradle/dependencies.gradle
gradle/dependencies.gradle
@@ -28,6 +28,7 @@ ext {
// OpenTelemetry
opentelemetryApi : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api', version: versions.opentelemetry),
opentelemetryApiAutoAnnotations: dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-contrib-auto-annotations', version: versions.opentelemetry),
+ opentelemetryTraceProps : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-contrib-trace-propagators', version: versions.opentelemetry),
opentelemetrySdk : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk', version: versions.opentelemetry),
opentelemetrySdkAutoConfig : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-contrib-auto-config', version: versions.opentelemetry),
opentelemetryJaeger : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-jaeger', version: versions.opentelemetry),

Initial Propagators support. (#389)