-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
3,186 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
instrumentation/rxjava/rxjava-3.0/javaagent/rxjava-3.0-javaagent.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apply from: "$rootDir/gradle/instrumentation.gradle" | ||
|
||
muzzle { | ||
pass { | ||
group = "io.reactivex.rxjava3" | ||
module = "rxjava" | ||
versions = "[3.0.0,)" | ||
assertInverse true | ||
} | ||
} | ||
|
||
dependencies { | ||
library group: 'io.reactivex.rxjava3', name: 'rxjava', version: "3.0.0" | ||
|
||
implementation project(":instrumentation:rxjava:rxjava-3.0:library") | ||
|
||
testImplementation deps.opentelemetryExtAnnotations | ||
testImplementation project(':instrumentation:rxjava:rxjava-3.0:testing') | ||
} |
58 changes: 58 additions & 0 deletions
58
.../src/main/java/io/opentelemetry/instrumentation/rxjava3/RxJava3InstrumentationModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.rxjava3; | ||
|
||
import static net.bytebuddy.matcher.ElementMatchers.isMethod; | ||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.javaagent.tooling.InstrumentationModule; | ||
import io.opentelemetry.javaagent.tooling.TypeInstrumentation; | ||
import io.reactivex.rxjava3.plugins.RxJavaPlugins; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
@AutoService(InstrumentationModule.class) | ||
public class RxJava3InstrumentationModule extends InstrumentationModule { | ||
|
||
public RxJava3InstrumentationModule() { | ||
super("rxjava3"); | ||
} | ||
|
||
@Override | ||
public List<TypeInstrumentation> typeInstrumentations() { | ||
return Collections.singletonList(new PluginInstrumentation()); | ||
} | ||
|
||
public static class PluginInstrumentation implements TypeInstrumentation { | ||
|
||
@Override | ||
public ElementMatcher<? super TypeDescription> typeMatcher() { | ||
return named("io.reactivex.rxjava3.plugins.RxJavaPlugins"); | ||
} | ||
|
||
@Override | ||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() { | ||
return Collections.singletonMap( | ||
isMethod(), RxJava3InstrumentationModule.class.getName() + "$RxJavaPluginsAdvice"); | ||
} | ||
} | ||
|
||
public static class RxJavaPluginsAdvice { | ||
|
||
// TODO(anuraaga): Replace with adding a type initializer to RxJavaPlugins | ||
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2685 | ||
@Advice.OnMethodEnter(suppress = Throwable.class) | ||
public static void activateOncePerClassloader() { | ||
TracingAssemblyActivation.activate(RxJavaPlugins.class); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ent/src/main/java/io/opentelemetry/instrumentation/rxjava3/TracingAssemblyActivation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.rxjava3; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public final class TracingAssemblyActivation { | ||
|
||
private static final ClassValue<AtomicBoolean> activated = | ||
new ClassValue<AtomicBoolean>() { | ||
@Override | ||
protected AtomicBoolean computeValue(Class<?> type) { | ||
return new AtomicBoolean(); | ||
} | ||
}; | ||
|
||
public static void activate(Class<?> clz) { | ||
if (activated.get(clz).compareAndSet(false, true)) { | ||
TracingAssembly.enable(); | ||
} | ||
} | ||
|
||
private TracingAssemblyActivation() {} | ||
} |
11 changes: 11 additions & 0 deletions
11
instrumentation/rxjava/rxjava-3.0/javaagent/src/test/groovy/RxJava3SubscriptionTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import io.opentelemetry.instrumentation.rxjava3.AbstractRxJava3SubscriptionTest | ||
import io.opentelemetry.instrumentation.test.AgentTestTrait | ||
|
||
class RxJava3SubscriptionTest extends AbstractRxJava3SubscriptionTest implements AgentTestTrait { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
instrumentation/rxjava/rxjava-3.0/javaagent/src/test/groovy/RxJava3Test.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import io.opentelemetry.instrumentation.rxjava3.AbstractRxJava3Test | ||
import io.opentelemetry.instrumentation.test.AgentTestTrait | ||
|
||
class RxJava3Test extends AbstractRxJava3Test implements AgentTestTrait { | ||
} |
Oops, something went wrong.