From c8f0ba392b931a08baa0ec1c0280a60c80e746de Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Oct 2021 15:51:59 -0700 Subject: [PATCH] Add Quartz and Apache Camel preview instrumentations (#1899) * Add Quartz preview instrumentation * And Apache Camel preview instrumentation * Statsbeat * Update lock files * Fix feature tracking for preview instrumentations * Fix instrumentations on default by OTEL * Fix spotlessApply Co-authored-by: Helen Yang --- .../agent/internal/configuration/Configuration.java | 5 +++++ .../agent/internal/init/ConfigOverride.java | 9 +++++++++ .../agent/internal/statsbeat/Feature.java | 9 ++++++--- .../agent/internal/statsbeat/FeatureStatsbeat.java | 10 ++++++++-- .../agent/internal/statsbeat/Instrumentations.java | 2 ++ agent/instrumentation/build.gradle.kts | 2 ++ agent/instrumentation/gradle.lockfile | 3 +++ 7 files changed, 35 insertions(+), 5 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/Configuration.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/Configuration.java index d937d4a2327..5977db39b45 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/Configuration.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/Configuration.java @@ -266,6 +266,9 @@ public static class InternalConfiguration { } public static class PreviewInstrumentation { + + public DisabledByDefaultInstrumentation apacheCamel = new DisabledByDefaultInstrumentation(); + // this is just here to detect if using this old setting in order to give a helpful message @Deprecated public DisabledByDefaultInstrumentation azureSdk = new DisabledByDefaultInstrumentation(); @@ -280,6 +283,8 @@ public static class PreviewInstrumentation { @Deprecated public DisabledByDefaultInstrumentation jaxws = new DisabledByDefaultInstrumentation(); + public DisabledByDefaultInstrumentation quartz = new DisabledByDefaultInstrumentation(); + // this is just here to detect if using this old setting in order to give a helpful message @Deprecated public DisabledByDefaultInstrumentation rabbitmq = new DisabledByDefaultInstrumentation(); diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/ConfigOverride.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/ConfigOverride.java index 3a48be857a2..ba4a2b473ee 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/ConfigOverride.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/ConfigOverride.java @@ -71,12 +71,21 @@ static Config getConfig(Configuration config) { if (!config.instrumentation.springScheduling.enabled) { properties.put("otel.instrumentation.spring-scheduling.enabled", "false"); } + if (!config.preview.instrumentation.apacheCamel.enabled) { + // apache-camel instrumentation is ON by default in OTEL + properties.put("otel.instrumentation.apache-camel.enabled", "false"); + } if (config.preview.instrumentation.grizzly.enabled) { // grizzly instrumentation is off by default // TODO (trask) investigate if grizzly instrumentation can be enabled upstream by default now properties.put("otel.instrumentation.grizzly.enabled", "true"); } + if (!config.preview.instrumentation.quartz.enabled) { + // quartz instrumentation is ON by default in OTEL + properties.put("otel.instrumentation.quartz.enabled", "false"); + } if (!config.preview.instrumentation.springIntegration.enabled) { + // springIntegration instrumentation is ON by default in OTEL properties.put("otel.instrumentation.spring-integration.enabled", "false"); } if (!config.preview.captureControllerSpans) { diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Feature.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Feature.java index 4f81d2f3e7a..6f8265c09a9 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Feature.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Feature.java @@ -46,10 +46,13 @@ enum Feature { // JAVA_HTTP_CLIENT_DISABLED(16), no longer used // JAXWS_DISABLED(17), no longer used RABBITMQ_DISABLED(18), - SPRING_INTEGRATION_DISABLED(19), + SPRING_INTEGRATION_DISABLED( + 19), // preview instrumentation, spring-integration is ON by default in OTEL LEGACY_PROPAGATION_DISABLED(20), - GRIZZLY_DISABLED(21), // preview instrumentation - STATSBEAT_DISABLED(22); // disable non-essential statsbeat + GRIZZLY_ENABLED(21), // preview instrumentation, grizzly is OFF by default in OTEL + STATSBEAT_DISABLED(22), // disable non-essential statsbeat + QUARTZ_DISABLED(23), // preview instrumentation, quartz is ON by default in OTEL + APACHE_CAMEL_DISABLED(24); // preview instrumentation, apache camel is ON by default in OTEL private static final Map javaVendorFeatureMap; diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/FeatureStatsbeat.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/FeatureStatsbeat.java index 76d4f1afd20..092acdbbad5 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/FeatureStatsbeat.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/FeatureStatsbeat.java @@ -129,8 +129,14 @@ void trackConfigurationOptions(Configuration config) { } // preview instrumentation - if (!config.preview.instrumentation.grizzly.enabled) { - featureList.add(Feature.GRIZZLY_DISABLED); + if (!config.preview.instrumentation.apacheCamel.enabled) { + featureList.add(Feature.APACHE_CAMEL_DISABLED); + } + if (config.preview.instrumentation.grizzly.enabled) { + featureList.add(Feature.GRIZZLY_ENABLED); + } + if (!config.preview.instrumentation.quartz.enabled) { + featureList.add(Feature.QUARTZ_DISABLED); } if (!config.preview.instrumentation.springIntegration.enabled) { featureList.add(Feature.SPRING_INTEGRATION_DISABLED); diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Instrumentations.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Instrumentations.java index 06f86871ad6..3f761785b33 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Instrumentations.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/statsbeat/Instrumentations.java @@ -118,6 +118,8 @@ class Instrumentations { INSTRUMENTATION_MAP.put("io.opentelemetry.jaxrs-client-2.0", 67); INSTRUMENTATION_MAP.put("io.opentelemetry.jaxrs-client-2.0-resteasy-3.0", 68); INSTRUMENTATION_MAP.put("io.opentelemetry.grizzly-2.0", 69); + INSTRUMENTATION_MAP.put("io.opentelemetry.quartz-2.0", 70); + INSTRUMENTATION_MAP.put("io.opentelemetry.apache-camel-2.20", 71); } // encode BitSet to a long diff --git a/agent/instrumentation/build.gradle.kts b/agent/instrumentation/build.gradle.kts index 8d1d26ea47e..c5889573afe 100644 --- a/agent/instrumentation/build.gradle.kts +++ b/agent/instrumentation/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { exclude("ch.qos.logback", "logback-core") } + implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-camel-2.20:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpasyncclient-4.1:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-2.0:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-4.0:$otelInstrumentationAlphaVersion") @@ -106,6 +107,7 @@ dependencies { implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-opentelemetry-annotations-1.0:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-opentelemetry-api-1.0:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-opentelemetry-api-metrics-1.0:$otelInstrumentationAlphaVersion") + implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-quartz-2.0:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-rabbitmq-2.7:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-reactor-3.1:$otelInstrumentationAlphaVersion") implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-reactor-netty-0.9:$otelInstrumentationAlphaVersion") diff --git a/agent/instrumentation/gradle.lockfile b/agent/instrumentation/gradle.lockfile index 50df55184d6..658bb3e9d04 100644 --- a/agent/instrumentation/gradle.lockfile +++ b/agent/instrumentation/gradle.lockfile @@ -66,6 +66,7 @@ io.opentelemetry.instrumentation:opentelemetry-lettuce-common:1.6.0+ai.patches-a io.opentelemetry.instrumentation:opentelemetry-mongo-3.1:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-netty-4.1:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0:1.6.0+ai.patches-alpha=runtimeClasspath +io.opentelemetry.instrumentation:opentelemetry-quartz-2.0:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-reactor-3.1:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-rxjava-2.0:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-rxjava-3.0:1.6.0+ai.patches-alpha=runtimeClasspath @@ -74,6 +75,7 @@ io.opentelemetry.instrumentation:opentelemetry-servlet-common:1.6.0+ai.patches-a io.opentelemetry.instrumentation:opentelemetry-servlet-javax-common:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-spring-integration-4.1:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.instrumentation:opentelemetry-spring-webflux-5.0:1.6.0+ai.patches-alpha=runtimeClasspath +io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-camel-2.20:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpasyncclient-4.1:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-2.0:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-4.0:1.6.0+ai.patches-alpha=runtimeClasspath @@ -145,6 +147,7 @@ io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-okhttp-3.0:1. io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-opentelemetry-annotations-1.0:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-opentelemetry-api-1.0:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-opentelemetry-api-metrics-1.0:1.6.0+ai.patches-alpha=runtimeClasspath +io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-quartz-2.0:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-rabbitmq-2.7:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-reactor-3.1:1.6.0+ai.patches-alpha=runtimeClasspath io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-reactor-netty-0.9:1.6.0+ai.patches-alpha=runtimeClasspath