From 2aad3cfe211d384101aa9acc92c7986f796ed6a9 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 14:44:56 -0700 Subject: [PATCH 01/10] Fix shading --- ...opentelemetry.instrumentation.javaagent-shadowing.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts index 06b9673a0627..34c97c4e3d7a 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts @@ -15,6 +15,8 @@ tasks.withType().configureEach { // rewrite dependencies calling Logger.getLogger relocate("java.util.logging.Logger", "io.opentelemetry.javaagent.bootstrap.PatchLogger") + relocate("javax.annotation", "io.opentelemetry.javaagent.shaded.javax.annotation") + // prevents conflict with library instrumentation relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation") From 6bf953ff241a51bfd2d0fd134346486cec8cc83a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 19:42:27 -0700 Subject: [PATCH 02/10] Revert "Fix shading" This reverts commit 2aad3cfe211d384101aa9acc92c7986f796ed6a9. --- ...opentelemetry.instrumentation.javaagent-shadowing.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts index 34c97c4e3d7a..06b9673a0627 100644 --- a/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts +++ b/conventions/src/main/kotlin/io.opentelemetry.instrumentation.javaagent-shadowing.gradle.kts @@ -15,8 +15,6 @@ tasks.withType().configureEach { // rewrite dependencies calling Logger.getLogger relocate("java.util.logging.Logger", "io.opentelemetry.javaagent.bootstrap.PatchLogger") - relocate("javax.annotation", "io.opentelemetry.javaagent.shaded.javax.annotation") - // prevents conflict with library instrumentation relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation") From 65fad772862b5b8b6f054ebb6a35ac4849a900ef Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 19:43:25 -0700 Subject: [PATCH 03/10] Make javax.annotations compileOnly --- benchmark-jfr-analyzer/build.gradle.kts | 4 ---- conventions/src/main/kotlin/otel.java-conventions.gradle.kts | 3 ++- dependencyManagement/build.gradle.kts | 2 +- instrumentation-api-annotation-support/build.gradle.kts | 1 - instrumentation-api-caching/build.gradle.kts | 2 -- instrumentation-api/build.gradle.kts | 1 - javaagent-bootstrap/build.gradle.kts | 1 - javaagent-extension-api/build.gradle.kts | 1 - javaagent-instrumentation-api/build.gradle.kts | 1 - 9 files changed, 3 insertions(+), 13 deletions(-) diff --git a/benchmark-jfr-analyzer/build.gradle.kts b/benchmark-jfr-analyzer/build.gradle.kts index abdb3914644f..07d0987696f3 100644 --- a/benchmark-jfr-analyzer/build.gradle.kts +++ b/benchmark-jfr-analyzer/build.gradle.kts @@ -7,7 +7,3 @@ tasks.withType().configureEach { release.set(11) } } - -dependencies { - implementation("com.google.code.findbugs:jsr305:3.0.2") -} diff --git a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts index 11772581714d..aec638470c28 100644 --- a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts @@ -94,7 +94,8 @@ dependencies { components.all() - compileOnly("org.checkerframework:checker-qual") + + compileOnly("com.google.code.findbugs:jsr305") testImplementation("org.junit.jupiter:junit-jupiter-api") testImplementation("org.junit.jupiter:junit-jupiter-params") diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index 87be4a27f3c7..032a4dd35e42 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -109,7 +109,7 @@ val DEPENDENCIES = listOf( "io.netty:netty:3.10.6.Final", "org.assertj:assertj-core:3.21.0", "org.awaitility:awaitility:4.1.0", - "org.checkerframework:checker-qual:3.14.0", + "com.google.code.findbugs:jsr305:3.0.2", "org.codehaus.groovy:groovy-all:${groovyVersion}", "org.objenesis:objenesis:3.2", "org.spockframework:spock-core:1.3-groovy-2.5", diff --git a/instrumentation-api-annotation-support/build.gradle.kts b/instrumentation-api-annotation-support/build.gradle.kts index 09e0c01de8af..446635d9de33 100644 --- a/instrumentation-api-annotation-support/build.gradle.kts +++ b/instrumentation-api-annotation-support/build.gradle.kts @@ -20,7 +20,6 @@ dependencies { implementation("io.opentelemetry:opentelemetry-api-metrics") implementation("org.slf4j:slf4j-api") - implementation("com.google.code.findbugs:jsr305:3.0.2") compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") diff --git a/instrumentation-api-caching/build.gradle.kts b/instrumentation-api-caching/build.gradle.kts index 8f91fcf41f34..f5c26abb2a92 100644 --- a/instrumentation-api-caching/build.gradle.kts +++ b/instrumentation-api-caching/build.gradle.kts @@ -20,8 +20,6 @@ val shadowInclude by configurations.creating { } dependencies { - implementation("com.google.code.findbugs:jsr305:3.0.2") - compileOnly(project(":instrumentation-api-caching:caffeine2", configuration = "shadow")) compileOnly(project(":instrumentation-api-caching:caffeine3", configuration = "shadow")) diff --git a/instrumentation-api/build.gradle.kts b/instrumentation-api/build.gradle.kts index 32098c085991..155fee8acd9c 100644 --- a/instrumentation-api/build.gradle.kts +++ b/instrumentation-api/build.gradle.kts @@ -30,7 +30,6 @@ dependencies { implementation("io.opentelemetry:opentelemetry-api-metrics") implementation("org.slf4j:slf4j-api") - implementation("com.google.code.findbugs:jsr305:3.0.2") compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") diff --git a/javaagent-bootstrap/build.gradle.kts b/javaagent-bootstrap/build.gradle.kts index e1d5c3edf674..da07d66ec13e 100644 --- a/javaagent-bootstrap/build.gradle.kts +++ b/javaagent-bootstrap/build.gradle.kts @@ -8,7 +8,6 @@ group = "io.opentelemetry.javaagent" dependencies { implementation(project(":instrumentation-api")) implementation("org.slf4j:slf4j-api") - implementation("com.google.code.findbugs:jsr305:3.0.2") testImplementation(project(":testing-common")) testImplementation("org.mockito:mockito-core") diff --git a/javaagent-extension-api/build.gradle.kts b/javaagent-extension-api/build.gradle.kts index 96188b276cc1..0ac62d41639e 100644 --- a/javaagent-extension-api/build.gradle.kts +++ b/javaagent-extension-api/build.gradle.kts @@ -13,7 +13,6 @@ dependencies { implementation(project(":instrumentation-api")) implementation(project(":javaagent-instrumentation-api")) implementation("org.slf4j:slf4j-api") - implementation("com.google.code.findbugs:jsr305:3.0.2") // metrics are unstable, do not expose as api implementation("io.opentelemetry:opentelemetry-sdk-metrics") diff --git a/javaagent-instrumentation-api/build.gradle.kts b/javaagent-instrumentation-api/build.gradle.kts index 77c0aa6467cc..ca4f0114f13a 100644 --- a/javaagent-instrumentation-api/build.gradle.kts +++ b/javaagent-instrumentation-api/build.gradle.kts @@ -11,7 +11,6 @@ dependencies { api(project(":instrumentation-api")) implementation("org.slf4j:slf4j-api") - implementation("com.google.code.findbugs:jsr305:3.0.2") compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") From 321081d1c0a7013556696d554412dd820ffd7c41 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 20:00:35 -0700 Subject: [PATCH 04/10] Replace checker GuardedBy with otel api internal GuardedBy --- .../opentelemetry/instrumentation/rxjava2/TracingAssembly.java | 2 +- .../opentelemetry/instrumentation/rxjava3/TracingAssembly.java | 2 +- .../api/internal/ClassLoaderMatcherCacheHolder.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java b/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java index 84049d001b4c..1c47ff03d815 100644 --- a/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java +++ b/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java @@ -22,6 +22,7 @@ package io.opentelemetry.instrumentation.rxjava2; +import io.opentelemetry.api.internal.GuardedBy; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategies; @@ -40,7 +41,6 @@ import io.reactivex.parallel.ParallelFlowable; import io.reactivex.plugins.RxJavaPlugins; import javax.annotation.Nullable; -import org.checkerframework.checker.lock.qual.GuardedBy; import org.reactivestreams.Subscriber; /** diff --git a/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java b/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java index 593feb96f34b..44cc9d056b36 100644 --- a/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java +++ b/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java @@ -22,6 +22,7 @@ package io.opentelemetry.instrumentation.rxjava3; +import io.opentelemetry.api.internal.GuardedBy; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategies; @@ -40,7 +41,6 @@ import io.reactivex.rxjava3.parallel.ParallelFlowable; import io.reactivex.rxjava3.plugins.RxJavaPlugins; import javax.annotation.Nullable; -import org.checkerframework.checker.lock.qual.GuardedBy; import org.reactivestreams.Subscriber; /** diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java index 90298591b233..4df89a2501db 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java @@ -5,11 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.api.internal; +import io.opentelemetry.api.internal.GuardedBy; import io.opentelemetry.instrumentation.api.caching.Cache; import java.net.URL; import java.util.ArrayList; import java.util.List; -import org.checkerframework.checker.lock.qual.GuardedBy; /** * A holder of all ClassLoaderMatcher caches. We store them in the bootstrap classloader so that From e5141ce3ce1ea852061134d9066e5913f0258dcb Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 20:08:05 -0700 Subject: [PATCH 05/10] Fix build --- instrumentation-api-caching/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation-api-caching/build.gradle.kts b/instrumentation-api-caching/build.gradle.kts index f5c26abb2a92..2a30d047f22b 100644 --- a/instrumentation-api-caching/build.gradle.kts +++ b/instrumentation-api-caching/build.gradle.kts @@ -23,6 +23,7 @@ dependencies { compileOnly(project(":instrumentation-api-caching:caffeine2", configuration = "shadow")) compileOnly(project(":instrumentation-api-caching:caffeine3", configuration = "shadow")) + compileOnly("org.checkerframework:checker-qual:3.14.0") compileOnly("com.blogspot.mydailyjava:weak-lock-free") shadowInclude("com.blogspot.mydailyjava:weak-lock-free") } From 28bf296eee753e36eac439d4695501ab77fa430e Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 20:23:54 -0700 Subject: [PATCH 06/10] Fix errorprone failures --- .../instrumentation/rxjava2/TracingAssembly.java | 12 ++++++++++++ .../instrumentation/rxjava3/TracingAssembly.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java b/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java index 1c47ff03d815..bab16e930aa5 100644 --- a/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java +++ b/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java @@ -158,6 +158,7 @@ public void disable() { } } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableParallel() { oldOnParallelAssembly = RxJavaPlugins.getOnParallelAssembly(); @@ -167,6 +168,7 @@ private static void enableParallel() { parallelFlowable -> new TracingParallelFlowable(parallelFlowable, Context.current()))); } + @GuardedBy("TracingAssembly.class") private static void enableCompletable() { oldOnCompletableSubscribe = RxJavaPlugins.getOnCompletableSubscribe(); RxJavaPlugins.setOnCompletableSubscribe( @@ -180,6 +182,7 @@ private static void enableCompletable() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableFlowable() { oldOnFlowableSubscribe = RxJavaPlugins.getOnFlowableSubscribe(); @@ -199,6 +202,7 @@ private static void enableFlowable() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableObservable() { if (TracingObserver.canEnable()) { @@ -215,6 +219,7 @@ private static void enableObservable() { } } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableSingle() { oldOnSingleSubscribe = RxJavaPlugins.getOnSingleSubscribe(); @@ -229,6 +234,7 @@ private static void enableSingle() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableMaybe() { oldOnMaybeSubscribe = RxJavaPlugins.getOnMaybeSubscribe(); @@ -256,31 +262,37 @@ private static void enableWithSpanStrategy(boolean captureExperimentalSpanAttrib AsyncOperationEndStrategies.instance().registerStrategy(asyncOperationEndStrategy); } + @GuardedBy("TracingAssembly.class") private static void disableParallel() { RxJavaPlugins.setOnParallelAssembly(oldOnParallelAssembly); oldOnParallelAssembly = null; } + @GuardedBy("TracingAssembly.class") private static void disableObservable() { RxJavaPlugins.setOnObservableSubscribe(oldOnObservableSubscribe); oldOnObservableSubscribe = null; } + @GuardedBy("TracingAssembly.class") private static void disableCompletable() { RxJavaPlugins.setOnCompletableSubscribe(oldOnCompletableSubscribe); oldOnCompletableSubscribe = null; } + @GuardedBy("TracingAssembly.class") private static void disableFlowable() { RxJavaPlugins.setOnFlowableSubscribe(oldOnFlowableSubscribe); oldOnFlowableSubscribe = null; } + @GuardedBy("TracingAssembly.class") private static void disableSingle() { RxJavaPlugins.setOnSingleSubscribe(oldOnSingleSubscribe); oldOnSingleSubscribe = null; } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void disableMaybe() { RxJavaPlugins.setOnMaybeSubscribe( diff --git a/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java b/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java index 44cc9d056b36..74de385be603 100644 --- a/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java +++ b/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java @@ -158,6 +158,7 @@ public void disable() { } } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableParallel() { oldOnParallelAssembly = RxJavaPlugins.getOnParallelAssembly(); @@ -167,6 +168,7 @@ private static void enableParallel() { parallelFlowable -> new TracingParallelFlowable(parallelFlowable, Context.current()))); } + @GuardedBy("TracingAssembly.class") private static void enableCompletable() { oldOnCompletableSubscribe = RxJavaPlugins.getOnCompletableSubscribe(); RxJavaPlugins.setOnCompletableSubscribe( @@ -180,6 +182,7 @@ private static void enableCompletable() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableFlowable() { oldOnFlowableSubscribe = RxJavaPlugins.getOnFlowableSubscribe(); @@ -199,6 +202,7 @@ private static void enableFlowable() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableObservable() { oldOnObservableSubscribe = RxJavaPlugins.getOnObservableSubscribe(); @@ -213,6 +217,7 @@ private static void enableObservable() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableSingle() { oldOnSingleSubscribe = RxJavaPlugins.getOnSingleSubscribe(); @@ -227,6 +232,7 @@ private static void enableSingle() { })); } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void enableMaybe() { oldOnMaybeSubscribe = RxJavaPlugins.getOnMaybeSubscribe(); @@ -254,31 +260,37 @@ private static void enableWithSpanStrategy(boolean captureExperimentalSpanAttrib AsyncOperationEndStrategies.instance().registerStrategy(asyncOperationEndStrategy); } + @GuardedBy("TracingAssembly.class") private static void disableParallel() { RxJavaPlugins.setOnParallelAssembly(oldOnParallelAssembly); oldOnParallelAssembly = null; } + @GuardedBy("TracingAssembly.class") private static void disableObservable() { RxJavaPlugins.setOnObservableSubscribe(oldOnObservableSubscribe); oldOnObservableSubscribe = null; } + @GuardedBy("TracingAssembly.class") private static void disableCompletable() { RxJavaPlugins.setOnCompletableSubscribe(oldOnCompletableSubscribe); oldOnCompletableSubscribe = null; } + @GuardedBy("TracingAssembly.class") private static void disableFlowable() { RxJavaPlugins.setOnFlowableSubscribe(oldOnFlowableSubscribe); oldOnFlowableSubscribe = null; } + @GuardedBy("TracingAssembly.class") private static void disableSingle() { RxJavaPlugins.setOnSingleSubscribe(oldOnSingleSubscribe); oldOnSingleSubscribe = null; } + @GuardedBy("TracingAssembly.class") @SuppressWarnings({"rawtypes", "unchecked"}) private static void disableMaybe() { RxJavaPlugins.setOnMaybeSubscribe( From def3286fa74f086b25078fc7f22558f931f94166 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Oct 2021 20:35:07 -0700 Subject: [PATCH 07/10] Remove extra newline --- conventions/src/main/kotlin/otel.java-conventions.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts index aec638470c28..6cc656678535 100644 --- a/conventions/src/main/kotlin/otel.java-conventions.gradle.kts +++ b/conventions/src/main/kotlin/otel.java-conventions.gradle.kts @@ -94,7 +94,6 @@ dependencies { components.all() - compileOnly("com.google.code.findbugs:jsr305") testImplementation("org.junit.jupiter:junit-jupiter-api") From e876676e3011b9a571fda423850dc297b8c8f76d Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 21 Oct 2021 10:58:20 -0700 Subject: [PATCH 08/10] Move internal GuardedBy to instrumentation-api --- .../api/internal/GuardedBy.java | 46 +++++++++++++++++++ .../rxjava2/TracingAssembly.java | 2 +- .../rxjava3/TracingAssembly.java | 2 +- .../ClassLoaderMatcherCacheHolder.java | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/GuardedBy.java diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/GuardedBy.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/GuardedBy.java new file mode 100644 index 000000000000..df8e0be4b2c8 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/GuardedBy.java @@ -0,0 +1,46 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The field or method to which this annotation is applied can only be accessed when holding a + * particular lock, which may be a built-in (synchronization) lock, or may be an explicit {@link + * java.util.concurrent.locks.Lock}. + * + *

The argument determines which lock guards the annotated field or method: + * + *

    + *
  • this : The string literal "this" means that this field is guarded by the class in which it + * is defined. + *
  • class-name.this : For inner classes, it may be necessary to disambiguate 'this'; the + * class-name.this designation allows you to specify which 'this' reference is intended + *
  • itself : For reference fields only; the object to which the field refers. + *
  • field-name : The lock object is referenced by the (instance or static) field specified by + * field-name. + *
  • class-name.field-name : The lock object is reference by the static field specified by + * class-name.field-name. + *
  • method-name() : The lock object is returned by calling the named nil-ary method. + *
  • class-name.class : The Class object for the specified class should be used as the lock + * object. + *
+ * + *

This annotation is similar to {@link javax.annotation.concurrent.GuardedBy} but has {@link + * RetentionPolicy#SOURCE} so it is not in published artifacts. We only apply this to private + * members, so there is no reason to publish them and we avoid requiring end users to have to depend + * on the annotations in their own build. See the original issue for more info. + */ +@Target({ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.SOURCE) +public @interface GuardedBy { + /** The name of the object guarding the target. */ + String value(); +} diff --git a/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java b/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java index bab16e930aa5..fb83abef8a5d 100644 --- a/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java +++ b/instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava2/TracingAssembly.java @@ -22,10 +22,10 @@ package io.opentelemetry.instrumentation.rxjava2; -import io.opentelemetry.api.internal.GuardedBy; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategies; +import io.opentelemetry.instrumentation.api.internal.GuardedBy; import io.reactivex.Completable; import io.reactivex.CompletableObserver; import io.reactivex.Flowable; diff --git a/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java b/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java index 74de385be603..58ab9c06aa15 100644 --- a/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java +++ b/instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssembly.java @@ -22,10 +22,10 @@ package io.opentelemetry.instrumentation.rxjava3; -import io.opentelemetry.api.internal.GuardedBy; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategies; +import io.opentelemetry.instrumentation.api.internal.GuardedBy; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.CompletableObserver; import io.reactivex.rxjava3.core.Flowable; diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java index 4df89a2501db..fbaecc2985e1 100644 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java +++ b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/internal/ClassLoaderMatcherCacheHolder.java @@ -5,8 +5,8 @@ package io.opentelemetry.javaagent.instrumentation.api.internal; -import io.opentelemetry.api.internal.GuardedBy; import io.opentelemetry.instrumentation.api.caching.Cache; +import io.opentelemetry.instrumentation.api.internal.GuardedBy; import java.net.URL; import java.util.ArrayList; import java.util.List; From 32b697b4c59131f6cc8741a17e74b3620da9b6b9 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 21 Oct 2021 12:44:29 -0700 Subject: [PATCH 09/10] empty commit From f6a04968be85980bfce5e2cf2268ca5bdaa986e1 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 21 Oct 2021 13:07:35 -0700 Subject: [PATCH 10/10] empty commit