/
ZioExecutorInstrumentation.scala
49 lines (36 loc) · 1.8 KB
/
ZioExecutorInstrumentation.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.bitlap.skywalking.apm.plugin.zio.v2x.define
import net.bytebuddy.description.method.MethodDescription
import net.bytebuddy.matcher.*
import net.bytebuddy.matcher.ElementMatchers.*
import org.apache.skywalking.apm.agent.core.plugin.`match`.*
import org.apache.skywalking.apm.agent.core.plugin.`match`.logical.LogicalMatchOperation
import org.apache.skywalking.apm.agent.core.plugin.interceptor.*
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.*
import org.bitlap.skywalking.apm.plugin.common.interceptor.*
final class ZioExecutorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine:
import ZioExecutorInstrumentation.*
override def enhanceClass(): ClassMatch = ENHANCE_CLASS
override def getConstructorsInterceptPoints: Array[ConstructorInterceptPoint] = null
override def getInstanceMethodsInterceptPoints: Array[InstanceMethodsInterceptPoint] =
methodInterceptors
.map(kv =>
new InstanceMethodsInterceptPoint {
override def getMethodsMatcher: ElementMatcher[MethodDescription] = kv._2
override def getMethodsInterceptor: String = kv._1
override def isOverrideArgs: Boolean = false
}
)
.toArray
end getInstanceMethodsInterceptPoints
end ZioExecutorInstrumentation
object ZioExecutorInstrumentation:
final val ENHANCE_CLASS = LogicalMatchOperation.or(
HierarchyMatch.byHierarchyMatch("zio.Executor"),
MultiClassNameMatch.byMultiClassMatch("zio.Executor")
)
final val SUBMIT_METHOD_INTERCEPTOR: String =
"org.bitlap.skywalking.apm.plugin.common.interceptor.CaptureContextOnSubmitInterceptor"
final val methodInterceptors: Map[String, ElementMatcher[MethodDescription]] =
Map(
SUBMIT_METHOD_INTERCEPTOR -> named("submit")
)