From ee4c978fc1769efcc0f9a02a52200b92fef5cff8 Mon Sep 17 00:00:00 2001 From: Vladimir Ryabtsev Date: Sat, 19 Oct 2024 12:48:50 -0700 Subject: [PATCH 1/2] Add repro for suppression bug --- SuppresAutoinstrumentation/.gitignore | 1 + SuppresAutoinstrumentation/pom.xml | 72 +++++++++++++++++++ .../src/main/java/My.java | 28 ++++++++ .../src/main/resources/log4j2.xml | 16 +++++ 4 files changed, 117 insertions(+) create mode 100644 SuppresAutoinstrumentation/.gitignore create mode 100644 SuppresAutoinstrumentation/pom.xml create mode 100644 SuppresAutoinstrumentation/src/main/java/My.java create mode 100644 SuppresAutoinstrumentation/src/main/resources/log4j2.xml 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/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 @@ + + + + + + + + + + + + + + + + From da0d40c5a2938083da668d1b798b44e0ac7a0246 Mon Sep 17 00:00:00 2001 From: Vladimir Ryabtsev Date: Sat, 19 Oct 2024 14:25:15 -0700 Subject: [PATCH 2/2] Add readme --- SuppresAutoinstrumentation/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 SuppresAutoinstrumentation/README.md 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