Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
118 lines (98 loc) · 4.18 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
118 lines (98 loc) · 4.18 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import java.time.Duration
plugins {
id("otel.library-instrumentation")
}
val baseAgent = configurations.create("baseAgent") {
isCanBeConsumed = false
isCanBeResolved = true
}
val jmxAgent = configurations.create("jmxAgent") {
isCanBeConsumed = false
isCanBeResolved = true
}
val testWebApp = configurations.create("testWebApp") {
isCanBeConsumed = false
isCanBeResolved = true
}
val camelTestApp = configurations.create("camelTestApp") {
isCanBeConsumed = false
isCanBeResolved = true
}
dependencies {
implementation("org.snakeyaml:snakeyaml-engine")
baseAgent(project(":javaagent", configuration = "baseJar"))
jmxAgent(project(":instrumentation:jmx-metrics:javaagent", configuration = "shadow"))
testWebApp(project(":instrumentation:jmx-metrics:testing-apps:testing-webapp", configuration = "testWebApp"))
camelTestApp(project(":instrumentation:jmx-metrics:testing-apps:camel-testing-app", configuration = "camelTestApp"))
testImplementation("io.opentelemetry.javaagent:opentelemetry-testing-common")
testImplementation("org.testcontainers:testcontainers")
testImplementation("org.testcontainers:testcontainers-junit-jupiter")
testImplementation("com.linecorp.armeria:armeria-junit5:1.31.3")
testImplementation("com.linecorp.armeria:armeria-grpc:1.31.3")
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha")
testImplementation("io.github.netmikey.logunit:logunit-jul")
testImplementation(platform("io.grpc:grpc-bom:1.82.1"))
testImplementation("io.grpc:grpc-netty-shaded")
}
tasks {
val containerTestPackage =
"io.opentelemetry.instrumentation.jmx.rules.containers"
val containerTestClasses = fileTree("src/test/java") {
include("${containerTestPackage.replace('.', '/')}/*Test.java")
}.files
.map { "$containerTestPackage.${it.nameWithoutExtension}" }
.sorted()
require(containerTestClasses.isNotEmpty()) {
"No JMX container test classes found"
}
test {
filter {
containerTestClasses.forEach { excludeTestsMatching(it) }
}
}
val containerTests = containerTestClasses.map { testClass ->
register<Test>("test${testClass.substringAfterLast('.').removeSuffix("Test")}") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
filter {
includeTestsMatching(testClass)
}
}
}
check {
dependsOn(containerTests)
}
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
// the base agent only contains the agent machinery and the internal instrumentations that it
// requires, the JMX instrumentation is added on top of it. Using the full agent would capture
// telemetry from the target systems that is unrelated to JMX metrics.
inputs.files(baseAgent)
.withPropertyName("javaagent")
.withNormalizer(ClasspathNormalizer::class)
inputs.files(jmxAgent)
.withPropertyName("jmxInstrumentation")
.withNormalizer(ClasspathNormalizer::class)
inputs.files(testWebApp)
.withPropertyName("testWebApp")
.withNormalizer(ClasspathNormalizer::class)
inputs.files(camelTestApp)
.withPropertyName("camelTestApp")
.withNormalizer(ClasspathNormalizer::class)
val agentJarPath = baseAgent.elements.map { it.single().asFile.absolutePath }
val jmxInstrumentationJarPath = jmxAgent.elements.map { it.single().asFile.absolutePath }
val testAppWarPath = testWebApp.elements.map { it.single().asFile.absolutePath }
val camelTestAppJarPath = camelTestApp.elements.map { it.single().asFile.absolutePath }
val registryDir = layout.projectDirectory.dir("../model").asFile.absolutePath
inputs.dir(registryDir).withPathSensitivity(PathSensitivity.RELATIVE)
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Dio.opentelemetry.javaagent.path=${agentJarPath.get()}",
"-Dio.opentelemetry.javaagent.jmx.path=${jmxInstrumentationJarPath.get()}",
"-Dio.opentelemetry.testapp.path=${testAppWarPath.get()}",
"-Dio.opentelemetry.registry.path=$registryDir",
"-Dio.opentelemetry.cameltestapp.path=${camelTestAppJarPath.get()}",
)
}
}
}