Skip to content

Commit

Permalink
Update to OpenTelemetry 1.17.0 (#2453)
Browse files Browse the repository at this point in the history
* Update to OpenTelemetry 1.17.0

* Add jdbc masking config

* Fixes

* Fix

* Fix

* Fix role name and ikey overrides

* Fix

* Fix

* Delete unused classes

* otelConfig
  • Loading branch information
trask authored Aug 23, 2022
1 parent 11ba60c commit d0e442b
Show file tree
Hide file tree
Showing 53 changed files with 549 additions and 455 deletions.
6 changes: 3 additions & 3 deletions agent/agent-bootstrap/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
com.squareup.moshi:moshi:1.11.0=runtimeClasspath
com.squareup.okio:okio:1.17.5=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-for-testing/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This file is expected to be part of source control.
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-gc-monitor/gc-monitor-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.errorprone:error_prone_annotations:2.14.0=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-gc-monitor/gc-monitor-core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.errorprone:error_prone_annotations:2.14.0=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-gc-monitor/gc-monitor-tests/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This file is expected to be part of source control.
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-profiler/agent-alerting-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This file is expected to be part of source control.
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-profiler/agent-alerting/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# This file is expected to be part of source control.
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-profiler/agent-diagnostics-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This file is expected to be part of source control.
com.azure:azure-sdk-bom:1.2.4=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
empty=
6 changes: 3 additions & 3 deletions agent/agent-profiler/agent-profiler-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ com.fasterxml.woodstox:woodstox-core:6.2.7=runtimeClasspath
com.google.guava:guava-bom:31.1-jre=runtimeClasspath
com.squareup.moshi:moshi:1.11.0=runtimeClasspath
com.squareup.okio:okio:1.17.5=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
io.projectreactor:reactor-core:3.4.19=runtimeClasspath
org.codehaus.woodstox:stax2-api:4.2.1=runtimeClasspath
org.junit:junit-bom:5.8.2=runtimeClasspath
Expand Down
6 changes: 3 additions & 3 deletions agent/agent-profiler/agent-service-profiler/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ io.netty:netty-transport-native-epoll:4.1.78.Final=runtimeClasspath
io.netty:netty-transport-native-kqueue:4.1.78.Final=runtimeClasspath
io.netty:netty-transport-native-unix-common:4.1.78.Final=runtimeClasspath
io.netty:netty-transport:4.1.78.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
io.projectreactor.netty:reactor-netty-core:1.0.20=runtimeClasspath
io.projectreactor.netty:reactor-netty-http:1.0.20=runtimeClasspath
io.projectreactor:reactor-core:3.4.19=runtimeClasspath
Expand Down
6 changes: 3 additions & 3 deletions agent/agent-tooling/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ io.netty:netty-transport-native-epoll:4.1.78.Final=runtimeClasspath
io.netty:netty-transport-native-kqueue:4.1.78.Final=runtimeClasspath
io.netty:netty-transport-native-unix-common:4.1.78.Final=runtimeClasspath
io.netty:netty-transport:4.1.78.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.16.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.16.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.17.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.17.0=runtimeClasspath
io.projectreactor.netty:reactor-netty-core:1.0.20=runtimeClasspath
io.projectreactor.netty:reactor-netty-http:1.0.20=runtimeClasspath
io.projectreactor:reactor-core:3.4.19=runtimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static class Instrumentation {

public EnabledByDefaultInstrumentation azureSdk = new EnabledByDefaultInstrumentation();
public EnabledByDefaultInstrumentation cassandra = new EnabledByDefaultInstrumentation();
public EnabledByDefaultInstrumentation jdbc = new EnabledByDefaultInstrumentation();
public JdbcInstrumentation jdbc = new JdbcInstrumentation();
public EnabledByDefaultInstrumentation jms = new EnabledByDefaultInstrumentation();
public EnabledByDefaultInstrumentation kafka = new EnabledByDefaultInstrumentation();
public LoggingInstrumentation logging = new LoggingInstrumentation();
Expand All @@ -204,6 +204,15 @@ public static class Instrumentation {
public EnabledByDefaultInstrumentation springScheduling = new EnabledByDefaultInstrumentation();
}

public static class JdbcInstrumentation {
public boolean enabled = true;
public JdbcMasking masking = new JdbcMasking();
}

public static class JdbcMasking {
public boolean enabled = true;
}

public static class LoggingInstrumentation {
public String level = "INFO";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
package com.microsoft.applicationinsights.agent.internal.init;

import com.google.auto.service.AutoService;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.tooling.bootstrap.BootstrapPackagesBuilder;
import io.opentelemetry.javaagent.tooling.bootstrap.BootstrapPackagesConfigurer;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;

@AutoService(BootstrapPackagesConfigurer.class)
public class AiBootstrapPackagesConfigurer implements BootstrapPackagesConfigurer {

@Override
public void configure(Config config, BootstrapPackagesBuilder bootstrapPackagesBuilder) {
public void configure(
BootstrapPackagesBuilder bootstrapPackagesBuilder, ConfigProperties config) {
bootstrapPackagesBuilder.add("com.microsoft.applicationinsights.agent.bootstrap");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,30 @@

import static java.util.concurrent.TimeUnit.SECONDS;

import com.google.auto.service.AutoService;
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration;
import com.microsoft.applicationinsights.agent.internal.legacyheaders.DelegatingPropagatorProvider;
import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;

@AutoService(ConfigPropertySource.class)
public class AiConfigCustomizer implements ConfigPropertySource {
public class AiConfigCustomizer implements Function<ConfigProperties, Map<String, String>> {

@Override
public Map<String, String> getProperties() {
Configuration config = FirstEntryPoint.getConfiguration();
public Map<String, String> apply(ConfigProperties otelConfig) {

Configuration configuration = FirstEntryPoint.getConfiguration();

Map<String, String> properties = new HashMap<>();
properties.put(
"otel.micrometer.step.millis",
Long.toString(SECONDS.toMillis(config.preview.metricIntervalSeconds)));
Long.toString(SECONDS.toMillis(configuration.preview.metricIntervalSeconds)));

enableInstrumentations(config, properties);
enableInstrumentations(configuration, properties);

if (!config.preview.captureControllerSpans) {
if (!configuration.preview.captureControllerSpans) {
properties.put(
"otel.instrumentation.common.experimental.controller-telemetry.enabled", "false");
}
Expand All @@ -60,19 +59,19 @@ public Map<String, String> getProperties() {
setHttpHeaderConfiguration(
properties,
"otel.instrumentation.http.capture-headers.server.request",
config.preview.captureHttpServerHeaders.requestHeaders);
configuration.preview.captureHttpServerHeaders.requestHeaders);
setHttpHeaderConfiguration(
properties,
"otel.instrumentation.http.capture-headers.server.response",
config.preview.captureHttpServerHeaders.responseHeaders);
configuration.preview.captureHttpServerHeaders.responseHeaders);
setHttpHeaderConfiguration(
properties,
"otel.instrumentation.http.capture-headers.client.request",
config.preview.captureHttpClientHeaders.requestHeaders);
configuration.preview.captureHttpClientHeaders.requestHeaders);
setHttpHeaderConfiguration(
properties,
"otel.instrumentation.http.capture-headers.client.response",
config.preview.captureHttpClientHeaders.responseHeaders);
configuration.preview.captureHttpClientHeaders.responseHeaders);

// enable capturing all mdc properties
properties.put(
Expand All @@ -93,10 +92,10 @@ public Map<String, String> getProperties() {
properties.put("otel.instrumentation.logback-appender.experimental-log-attributes", "true");

// custom instrumentation
if (!config.preview.customInstrumentation.isEmpty()) {
if (!configuration.preview.customInstrumentation.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (Configuration.CustomInstrumentation customInstrumentation :
config.preview.customInstrumentation) {
configuration.preview.customInstrumentation) {
if (sb.length() > 0) {
sb.append(';');
}
Expand All @@ -112,44 +111,37 @@ public Map<String, String> getProperties() {

properties.put("otel.traces.sampler", DelegatingSamplerProvider.NAME);

String tracesExporter = getProperty("otel.traces.exporter");
String tracesExporter = otelConfig.getString("otel.traces.exporter");
if (tracesExporter == null) {
// currently Application Insights Exporter has to be configured manually because it relies on
// using a BatchSpanProcessor with queue size 1 due to live metrics (this will change in the
// future)
// this overrides the default "otlp" so the exporter can be configured later
properties.put("otel.traces.exporter", "none");

// TODO (trask) this can go away once new indexer is rolled out to gov clouds
List<String> httpClientResponseHeaders = new ArrayList<>();
httpClientResponseHeaders.add("request-context");
httpClientResponseHeaders.addAll(config.preview.captureHttpClientHeaders.responseHeaders);
httpClientResponseHeaders.addAll(
configuration.preview.captureHttpClientHeaders.responseHeaders);
setHttpHeaderConfiguration(
properties,
"otel.instrumentation.http.capture-headers.client.response",
httpClientResponseHeaders);
} else {
properties.put("otel.traces.exporter", tracesExporter);
}

String metricsExporter = getProperty("otel.metrics.exporter");
String metricsExporter = otelConfig.getString("otel.metrics.exporter");
if (metricsExporter == null) {
// the metrics exporter is configured later in this case
// this overrides the default "otlp" so the exporter can be configured later
properties.put("otel.metrics.exporter", "none");
} else {
properties.put("otel.metrics.exporter", metricsExporter);
}

String logsExporter = getProperty("otel.logs.exporter");
String logsExporter = otelConfig.getString("otel.logs.exporter");
if (logsExporter == null) {
// the logs exporter is configured later in this case
// this overrides the default "otlp" so the exporter can be configured later
properties.put("otel.logs.exporter", "none");
} else {
properties.put("otel.logs.exporter", logsExporter);
}

if (config.role.name != null) {
if (configuration.role.name != null) {
// in case using another exporter
properties.put("otel.service.name", config.role.name);
properties.put("otel.service.name", configuration.role.name);
}

return properties;
Expand Down Expand Up @@ -230,6 +222,12 @@ private static void enableInstrumentations(Configuration config, Map<String, Str
}
if (config.instrumentation.jdbc.enabled) {
properties.put("otel.instrumentation.jdbc.enabled", "true");
if (!config.instrumentation.jdbc.masking.enabled) {
properties.put("otel.instrumentation.jdbc.statement-sanitizer.enabled", "false");
// TODO (trask) this line is temporary until 1.18.0, see
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/6492
System.setProperty("otel.instrumentation.jdbc.statement-sanitizer.enabled", "false");
}
}
if (config.instrumentation.jms.enabled) {
properties.put("otel.instrumentation.jms.enabled", "true");
Expand Down Expand Up @@ -290,15 +288,6 @@ private static void setHttpHeaderConfiguration(
}
}

private static String getProperty(String propertyName) {
String value = System.getProperty(propertyName);
if (value != null) {
return value;
}
String envVarName = propertyName.replace('.', '_').toUpperCase(Locale.ROOT);
return System.getenv(envVarName);
}

private static <T> String join(List<T> values, char separator) {
StringBuilder sb = new StringBuilder();
for (Object val : values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,19 @@
* DEALINGS IN THE SOFTWARE.
*/

package com.azure.monitor.opentelemetry.exporter.implementation;
package com.microsoft.applicationinsights.agent.internal.init;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.logs.data.Body;
import io.opentelemetry.sdk.logs.data.LogData;

// TODO (trask) delete after updating to 1.17.0
public class MyLogData extends DelegatingLogData {

private final Attributes attributes;
private final Body body;

public MyLogData(LogData delegate, Attributes attributes) {
this(delegate, attributes, delegate.getBody());
}

public MyLogData(LogData delegate, Attributes attributes, Body body) {
super(delegate);
this.attributes = attributes;
this.body = body;
}

@Override
public Body getBody() {
return body;
}
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
import java.util.Collections;
import java.util.Map;

@AutoService(ConfigPropertySource.class)
public class AiConfigPropertySource implements ConfigPropertySource {
@Override
public Attributes getAttributes() {
return attributes;
public Map<String, String> getProperties() {
// TODO (trask) this is temporary until 1.18.0, see
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/6491
return Collections.singletonMap("otel.instrumentation.common.default-enabled", "false");
}
}
Loading

0 comments on commit d0e442b

Please sign in to comment.