Extract Akka context propagation into separate module (#911)

This commit is contained in:
Nikita Salnikov-Tarnovski 2020-08-08 06:24:26 +03:00 committed by GitHub
parent 1d80e19812
commit 3b68c82f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 34 additions and 58 deletions

View File

@ -0,0 +1,10 @@
apply from: "$rootDir/gradle/instrumentation.gradle"
apply from: "$rootDir/gradle/test-with-scala.gradle"
dependencies {
implementation project(':instrumentation:java-concurrent')
compileOnly group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0'
testImplementation deps.scala
testImplementation group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0'
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.opentelemetry.auto.instrumentation.javaconcurrent;
package io.opentelemetry.auto.instrumentation.akkaconcurrent;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
@ -28,6 +28,7 @@ import io.opentelemetry.auto.bootstrap.ContextStore;
import io.opentelemetry.auto.bootstrap.InstrumentationContext;
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.ExecutorInstrumentationUtils;
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.State;
import io.opentelemetry.auto.instrumentation.javaconcurrent.AbstractExecutorInstrumentation;
import io.opentelemetry.auto.tooling.Instrumenter;
import java.util.HashMap;
import java.util.Map;
@ -40,7 +41,12 @@ import net.bytebuddy.matcher.ElementMatcher;
public final class AkkaExecutorInstrumentation extends AbstractExecutorInstrumentation {
public AkkaExecutorInstrumentation() {
super(EXEC_NAME + ".akka_fork_join");
super(AbstractExecutorInstrumentation.EXEC_NAME + ".akka_fork_join");
}
@Override
protected boolean defaultEnabled() {
return false;
}
@Override

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.opentelemetry.auto.instrumentation.javaconcurrent;
package io.opentelemetry.auto.instrumentation.akkaconcurrent;
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
@ -31,6 +31,7 @@ import io.opentelemetry.auto.bootstrap.ContextStore;
import io.opentelemetry.auto.bootstrap.InstrumentationContext;
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.AdviceUtils;
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.State;
import io.opentelemetry.auto.instrumentation.javaconcurrent.AbstractExecutorInstrumentation;
import io.opentelemetry.auto.tooling.Instrumenter;
import io.opentelemetry.context.Scope;
import java.util.Collections;
@ -54,7 +55,12 @@ public final class AkkaForkJoinTaskInstrumentation extends Instrumenter.Default
static final String TASK_CLASS_NAME = "akka.dispatch.forkjoin.ForkJoinTask";
public AkkaForkJoinTaskInstrumentation() {
super(AbstractExecutorInstrumentation.EXEC_NAME);
super(AbstractExecutorInstrumentation.EXEC_NAME + ".akka_fork_join");
}
@Override
protected boolean defaultEnabled() {
return false;
}
@Override

View File

@ -18,8 +18,6 @@ import akka.dispatch.forkjoin.ForkJoinPool
import akka.dispatch.forkjoin.ForkJoinTask
import io.opentelemetry.auto.test.AgentTestRunner
import io.opentelemetry.sdk.trace.data.SpanData
import spock.lang.Shared
import java.lang.reflect.InvocationTargetException
import java.util.concurrent.ArrayBlockingQueue
import java.util.concurrent.Callable
@ -27,6 +25,7 @@ import java.util.concurrent.Future
import java.util.concurrent.RejectedExecutionException
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import spock.lang.Shared
import static io.opentelemetry.auto.test.utils.TraceUtils.runUnderTrace
@ -36,6 +35,10 @@ import static io.opentelemetry.auto.test.utils.TraceUtils.runUnderTrace
*/
class AkkaExecutorInstrumentationTest extends AgentTestRunner {
static {
System.setProperty("otel.integration.java_concurrent.akka_fork_join.enabled", "true")
}
@Shared
def executeRunnable = { e, c -> e.execute((Runnable) c) }
@Shared
@ -127,7 +130,7 @@ class AkkaExecutorInstrumentationTest extends AgentTestRunner {
throw e.getCause()
}
}
} catch (RejectedExecutionException e) {
} catch (RejectedExecutionException ignored) {
}
for (Future f : jobFutures) {

View File

@ -1,19 +0,0 @@
// Set properties before any plugins get loaded
ext {
minJavaVersionForTests = JavaVersion.VERSION_1_8
skipPublish = true
retryTests = true
}
apply from: "$rootDir/gradle/instrumentation.gradle"
apply from: "$rootDir/gradle/test-with-scala.gradle"
dependencies {
compileOnly deps.scala
testImplementation deps.scala
testImplementation group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0'
testImplementation project(':instrumentation:java-concurrent')
testImplementation project(':instrumentation:annotations')
}

View File

@ -1,17 +0,0 @@
ext {
skipPublish = true
retryTests = true
}
apply from: "$rootDir/gradle/instrumentation.gradle"
apply from: "$rootDir/gradle/test-with-scala.gradle"
dependencies {
compileOnly deps.scala
testImplementation deps.scala
testImplementation group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.3.16'
testImplementation group: 'com.typesafe.akka', name: 'akka-testkit_2.11', version: '2.3.16'
testImplementation project(':instrumentation:java-concurrent')
testImplementation project(':instrumentation:annotations')
}

View File

@ -20,8 +20,6 @@ compileSlickTestGroovy {
dependencies {
// This is needed for Scala ForJoinTask/Pool instrumentation
compileOnly deps.scala
// This is needed for Akka ForJoinTask/Pool instrumentation
compileOnly group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0'
testImplementation project(':instrumentation:annotations')
@ -34,13 +32,4 @@ dependencies {
}
// Run Slick library tests along with the rest of unit tests
test.dependsOn slickTest
// Until custom source sets can use minJavaVersionForTests separately from other tests
// force this one test to run on java8 only
slickTest {
onlyIf {
String java8Home = findJavaHome(JavaVersion.VERSION_1_8)
java8Home != null && executable == toExecutable(java8Home)
}
}
test.dependsOn slickTest

View File

@ -40,6 +40,7 @@ include ':smoke-tests:wildfly'
include ':smoke-tests:springboot'
// instrumentation:
include ':instrumentation:akka-context-propagation'
include ':instrumentation:akka-http-10.0'
include ':instrumentation:annotations'
include ':instrumentation:apache-httpasyncclient-4.0'
@ -84,11 +85,8 @@ include ':instrumentation:java-classloader:jboss-testing'
include ':instrumentation:java-classloader:osgi-testing'
include ':instrumentation:java-classloader:tomcat-testing'
include ':instrumentation:java-concurrent'
include ':instrumentation:java-concurrent:java-completablefuture'
include ':instrumentation:java-concurrent:kotlin-testing'
include ':instrumentation:java-concurrent:scala-testing'
include ':instrumentation:java-concurrent:akka-testing'
include ':instrumentation:java-concurrent:akka-2.5-testing'
include ':instrumentation:jaxrs:jaxrs-1.0'
include ':instrumentation:jaxrs:jaxrs-2.0'
include ':instrumentation:jaxrs:jaxrs-2.0:jaxrs-2.0-jersey-2.0'