diff --git a/SuppresAutoinstrumentation/.gitignore b/SuppresAutoinstrumentation/.gitignore new file mode 100644 index 0000000..2e73990 --- /dev/null +++ b/SuppresAutoinstrumentation/.gitignore @@ -0,0 +1 @@ +dependency-reduced-pom.xml \ No newline at end of file diff --git a/SuppresAutoinstrumentation/README.md b/SuppresAutoinstrumentation/README.md new file mode 100644 index 0000000..d014879 --- /dev/null +++ b/SuppresAutoinstrumentation/README.md @@ -0,0 +1 @@ +See [issue 3919](https://github.com/microsoft/ApplicationInsights-Java/issues/3919) \ No newline at end of file diff --git a/SuppresAutoinstrumentation/pom.xml b/SuppresAutoinstrumentation/pom.xml new file mode 100644 index 0000000..8b2e620 --- /dev/null +++ b/SuppresAutoinstrumentation/pom.xml @@ -0,0 +1,72 @@ + + 4.0.0 + + com.example + my-project + 1.0-SNAPSHOT + + + + + io.opentelemetry.instrumentation + opentelemetry-instrumentation-bom + 2.9.0 + pom + import + + + + + + + + org.apache.logging.log4j + log4j-core + 2.24.1 + + + org.apache.logging.log4j + log4j-api + 2.24.1 + + + + + io.opentelemetry + opentelemetry-api + + + io.opentelemetry + opentelemetry-semconv + 1.30.1-alpha + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + My + + + + + + + + + + diff --git a/SuppresAutoinstrumentation/src/main/java/My.java b/SuppresAutoinstrumentation/src/main/java/My.java new file mode 100644 index 0000000..bcf45ce --- /dev/null +++ b/SuppresAutoinstrumentation/src/main/java/My.java @@ -0,0 +1,28 @@ +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import io.opentelemetry.context.Scope; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.api.trace.Span; + +import io.opentelemetry.api.GlobalOpenTelemetry; + +public class My { + private static final Logger logger = LogManager.getLogger("root"); + private static final Tracer tracer = GlobalOpenTelemetry.getTracer("my-project"); + + public static void main(String[] args) throws InterruptedException { + logger.warn("Hello Azure"); + + Span span = tracer.spanBuilder("My-span").startSpan(); + + try (Scope scope = span.makeCurrent()) { + Thread.sleep(1000L); // Work simulation + logger.info("Log from a trace"); + } + finally { + span.end(); + } + Thread.sleep(10000); + } +} \ No newline at end of file diff --git a/SuppresAutoinstrumentation/src/main/resources/log4j2.xml b/SuppresAutoinstrumentation/src/main/resources/log4j2.xml new file mode 100644 index 0000000..c40335b --- /dev/null +++ b/SuppresAutoinstrumentation/src/main/resources/log4j2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +