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

Move diagnostics package out of bootstrap module #3190

Merged
merged 10 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 2 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ updates:
registries:
- gradle-plugin-portal
ignore:
- dependency-name: "org.slf4j:*"
# moving to 2.0 is problematic because the SPI mechanism in 2.0 doesn't work in the
# bootstrap class loader because, while we add the agent jar to the bootstrap class loader
# via Instrumentation.appendToBootstrapClassLoaderSearch(), there's nothing similar for
# resources (which is a known problem in the java agent world), and so the META-INF/services
# resource is not found
versions: [ "[2,)" ]
- dependency-name: "ch.qos.logback:*"
# logback version is pinned to slf4j version (see above comment for slf4j version)
versions: [ "[1.3,)" ]
# logback 1.4+ requires Java 11+
versions: [ "[1.4,)" ]
- dependency-name: "com.squareup.moshi:*"
# 1.12.0 and above use okio 2.x which pulls in kotlin libs (which are large)
versions: [ "[1.12,)" ]
Expand Down
20 changes: 0 additions & 20 deletions agent/agent-bootstrap/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,4 @@ dependencies {
// TODO (heya) remove this when updating to upstream micrometer instrumentation
compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
compileOnly("io.opentelemetry:opentelemetry-semconv")
compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv")

compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

implementation("ch.qos.logback:logback-classic")
implementation("ch.qos.logback.contrib:logback-json-classic")

// not using gson because it has dependency on java.sql.*, which is not available in Java 9+ bootstrap class loader
// only complaint so far about moshi is that it doesn"t give line numbers when there are json formatting errors
implementation("com.squareup.moshi:moshi")
Comment on lines -19 to -21
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was what motivated moving this code out of the bootstrap module (in addition to it being a generally good thing to minimize amount of classes in the bootstrap module)

(although this comment is now very outdated, and we'll move to jackson)


implementation(project(":etw:java"))

testCompileOnly("com.google.code.findbugs:jsr305")

testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.assertj:assertj-core")
testImplementation("org.mockito:mockito-core")
testImplementation("uk.org.webcompere:system-stubs-jupiter:2.0.2")
}
7 changes: 0 additions & 7 deletions agent/agent-bootstrap/gradle.lockfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
ch.qos.logback.contrib:logback-json-classic:0.1.5=runtimeClasspath
ch.qos.logback.contrib:logback-json-core:0.1.5=runtimeClasspath
ch.qos.logback:logback-classic:1.2.12=runtimeClasspath
ch.qos.logback:logback-core:1.2.12=runtimeClasspath
com.azure:azure-sdk-bom:1.2.14=runtimeClasspath
com.fasterxml.jackson:jackson-bom:2.15.2=runtimeClasspath
com.google.guava:guava-bom:32.1.1-jre=runtimeClasspath
com.squareup.moshi:moshi:1.11.0=runtimeClasspath
com.squareup.okio:okio:1.17.5=runtimeClasspath
io.netty:netty-bom:4.1.94.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.27.0-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:1.27.0=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.27.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.27.0=runtimeClasspath
org.junit:junit-bom:5.9.3=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
org.testcontainers:testcontainers-bom:1.18.3=runtimeClasspath
empty=
2 changes: 1 addition & 1 deletion agent/agent-gc-monitor/gc-monitor-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:1.27.0=runtim
io.opentelemetry:opentelemetry-bom-alpha:1.27.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.27.0=runtimeClasspath
org.junit:junit-bom:5.9.3=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
org.slf4j:slf4j-api:2.0.7=runtimeClasspath
org.testcontainers:testcontainers-bom:1.18.3=runtimeClasspath
empty=
2 changes: 1 addition & 1 deletion agent/agent-gc-monitor/gc-monitor-core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:1.27.0=runtim
io.opentelemetry:opentelemetry-bom-alpha:1.27.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.27.0=runtimeClasspath
org.junit:junit-bom:5.9.3=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
org.slf4j:slf4j-api:2.0.7=runtimeClasspath
org.testcontainers:testcontainers-bom:1.18.3=runtimeClasspath
empty=
2 changes: 1 addition & 1 deletion agent/agent-profiler/agent-alerting/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:1.27.0=runtim
io.opentelemetry:opentelemetry-bom-alpha:1.27.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.27.0=runtimeClasspath
org.junit:junit-bom:5.9.3=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
org.slf4j:slf4j-api:2.0.7=runtimeClasspath
org.testcontainers:testcontainers-bom:1.18.3=runtimeClasspath
empty=
8 changes: 5 additions & 3 deletions agent/agent-tooling/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation(project(":agent:azure-monitor-exporter")) {
exclude("org.ow2.asm", "asm")
}
implementation(project(":etw:java"))

compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
Expand All @@ -37,9 +38,8 @@ dependencies {
// TODO (trask) this is probably still needed for above apache commons projects
implementation("org.slf4j:jcl-over-slf4j")

// these are present in the bootstrap class loader
compileOnly("ch.qos.logback:logback-classic")
compileOnly("ch.qos.logback.contrib:logback-json-classic")
implementation("ch.qos.logback:logback-classic")
implementation("ch.qos.logback.contrib:logback-json-classic")

implementation("com.azure:azure-core")
implementation("com.azure:azure-identity") {
Expand Down Expand Up @@ -88,4 +88,6 @@ dependencies {
testImplementation("org.mockito:mockito-core")
testImplementation("uk.org.webcompere:system-stubs-jupiter:2.0.2")
testImplementation("io.github.hakky54:logcaptor")

testCompileOnly("com.google.code.findbugs:jsr305")
}
8 changes: 6 additions & 2 deletions agent/agent-tooling/gradle.lockfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
ch.qos.logback.contrib:logback-json-classic:0.1.5=runtimeClasspath
ch.qos.logback.contrib:logback-json-core:0.1.5=runtimeClasspath
ch.qos.logback:logback-classic:1.3.8=runtimeClasspath
ch.qos.logback:logback-core:1.3.8=runtimeClasspath
com.azure:azure-core-http-netty:1.13.4=runtimeClasspath
com.azure:azure-core:1.40.0=runtimeClasspath
com.azure:azure-identity:1.9.1=runtimeClasspath
Expand Down Expand Up @@ -69,7 +73,7 @@ org.apache.commons:commons-text:1.10.0=runtimeClasspath
org.codehaus.woodstox:stax2-api:4.2.1=runtimeClasspath
org.junit:junit-bom:5.9.3=runtimeClasspath
org.reactivestreams:reactive-streams:1.0.4=runtimeClasspath
org.slf4j:jcl-over-slf4j:1.7.36=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
org.slf4j:jcl-over-slf4j:2.0.7=runtimeClasspath
org.slf4j:slf4j-api:2.0.7=runtimeClasspath
org.testcontainers:testcontainers-bom:1.18.3=runtimeClasspath
empty=
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import static org.objectweb.asm.Opcodes.NEW;
import static org.objectweb.asm.Opcodes.RETURN;

import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.status.StatusFile;
import com.microsoft.applicationinsights.agent.internal.diagnostics.status.StatusFile;
import java.lang.instrument.ClassFileTransformer;
import java.security.ProtectionDomain;
import javax.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.status.StatusFile;
import com.microsoft.applicationinsights.agent.internal.common.FriendlyException;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.internal.diagnostics.status.StatusFile;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.logs.Severity;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.internal.common.FriendlyException;
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.ConnectionStringOverride;
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.InstrumentationKeyOverride;
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.JmxMetric;
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.SamplingOverride;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

public class AgentExtensionVersionFinder extends CachedDiagnosticsValueFinder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import java.util.Arrays;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

public abstract class CachedDiagnosticsValueFinder implements DiagnosticsValueFinder {
private volatile String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import java.nio.file.Files;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

public interface DiagnosticsValueFinder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

public class InstrumentationKeyFinder implements DiagnosticsValueFinder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import org.slf4j.MDC;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
package com.microsoft.applicationinsights.agent.internal.diagnostics;

public class SubscriptionIdFinder extends CachedDiagnosticsValueFinder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw;
package com.microsoft.applicationinsights.agent.internal.diagnostics.etw;

import static com.microsoft.applicationinsights.agent.bootstrap.diagnostics.MsgId.INITIALIZATION_SUCCESS;
import static com.microsoft.applicationinsights.agent.internal.diagnostics.MsgId.INITIALIZATION_SUCCESS;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.ThrowableProxyUtil;
import ch.qos.logback.core.AppenderBase;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.ApplicationMetadataFactory;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaError;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaInfo;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaVerbose;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaWarn;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.model.IpaEtwEventBase;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.status.StatusFile;
import com.microsoft.applicationinsights.agent.internal.diagnostics.ApplicationMetadataFactory;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.internal.diagnostics.etw.events.IpaError;
import com.microsoft.applicationinsights.agent.internal.diagnostics.etw.events.IpaInfo;
import com.microsoft.applicationinsights.agent.internal.diagnostics.etw.events.IpaVerbose;
import com.microsoft.applicationinsights.agent.internal.diagnostics.etw.events.IpaWarn;
import com.microsoft.applicationinsights.agent.internal.diagnostics.etw.events.model.IpaEtwEventBase;
import com.microsoft.applicationinsights.agent.internal.diagnostics.status.StatusFile;
import java.util.Map;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -63,8 +63,7 @@ public void start() {
protected void append(ILoggingEvent logEvent) {
String logger = logEvent.getLoggerName();
if (logger != null
&& logger.startsWith(
"com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.")) {
&& logger.startsWith("com.microsoft.applicationinsights.agent.internal.diagnostics.etw.")) {
addWarn("Skipping attempt to log to " + logger);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.log;
package com.microsoft.applicationinsights.agent.internal.diagnostics.log;

import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.ThrowableProxy;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.ApplicationMetadataFactory;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.internal.diagnostics.ApplicationMetadataFactory;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.PrintWriter;
import java.io.StringWriter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.log;
package com.microsoft.applicationinsights.agent.internal.diagnostics.log;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;

public class ApplicationInsightsDiagnosticsLogFilter extends Filter<ILoggingEvent> {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.log;
package com.microsoft.applicationinsights.agent.internal.diagnostics.log;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.contrib.json.classic.JsonLayout;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.ApplicationMetadataFactory;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsValueFinder;
import com.microsoft.applicationinsights.agent.internal.diagnostics.ApplicationMetadataFactory;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsValueFinder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.log;
package com.microsoft.applicationinsights.agent.internal.diagnostics.log;

import ch.qos.logback.contrib.json.JsonFormatter;
import com.squareup.moshi.Moshi;
Expand Down
Loading
Loading