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

Update to OpenTelemetry 1.17.0 #2453

Merged
merged 11 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
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 {
trask marked this conversation as resolved.
Show resolved Hide resolved
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 config) {

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 = config.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 = config.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 = config.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
@@ -0,0 +1,37 @@
/*
* ApplicationInsights-Java
* Copyright (c) Microsoft Corporation
* All rights reserved.
*
* MIT License
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the ""Software""), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

package com.microsoft.applicationinsights.agent.internal.init;

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 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