-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
174 lines (144 loc) · 6.57 KB
/
build.gradle
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
plugins {
id "java"
/*
Instrumentation agent extension mechanism expects a single jar containing everything required
for your extension. This also includes any external libraries that your extension uses and
cannot access from application classpath (see comment below about `javax.servlet-api` dependency).
Thus we use Shadow Gradle plugin to package our classes and all required runtime dependencies
into a single jar.
See https://imperceptiblethoughts.com/shadow/ for more details about Shadow plugin.
*/
id "com.github.johnrengelman.shadow" version "8.1.1"
id "com.diffplug.spotless" version "6.17.0"
id "io.opentelemetry.instrumentation.muzzle-generation" version "1.25.0-alpha-SNAPSHOT"
id "io.opentelemetry.instrumentation.muzzle-check" version "1.25.0-alpha-SNAPSHOT"
}
group 'ai.mypulse'
version System.getenv('VERSION') ?: "0.0.0+LOCAL"
ext {
versions = [
// this line is managed by .github/scripts/update-sdk-version.sh
opentelemetrySdk : "1.24.0",
// these lines are managed by .github/scripts/update-version.sh
opentelemetryJavaagent : "1.25.0-SNAPSHOT",
opentelemetryJavaagentAlpha: "1.25.0-alpha-SNAPSHOT",
junit : "5.9.2"
]
deps = [
autoservice: dependencies.create(group: 'com.google.auto.service', name: 'auto-service', version: '1.0.1')
]
}
repositories {
mavenCentral()
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
configurations {
/*
We create a separate gradle configuration to grab a published Otel instrumentation agent.
We don't need the agent during development of this extension module.
This agent is used only during integration test.
*/
otel
}
spotless {
java {
googleJavaFormat()
target("src/**/*.java")
}
}
dependencies {
implementation(platform("io.opentelemetry:opentelemetry-bom:${versions.opentelemetrySdk}"))
// these serve as a test of the instrumentation boms
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:${versions.opentelemetryJavaagent}"))
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${versions.opentelemetryJavaagentAlpha}"))
/*
Interfaces and SPIs that we implement. We use `compileOnly` dependency because during
runtime all necessary classes are provided by javaagent itself.
*/
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
//Provides @AutoService annotation that makes registration of our SPI implementations much easier
compileOnly deps.autoservice
annotationProcessor deps.autoservice
/*
Used by our demo instrumentation module to reference classes of the target instrumented library.
We again use `compileOnly` here because during runtime these classes are provided by the
actual application that we instrument.
NB! Only Advice (and "helper") classes of instrumentation modules can access classes from application classpath.
See https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/writing-instrumentation-module.md#advice-classes
*/
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
/*
This dependency is required for DemoSpanProcessor both during compile and runtime.
Only dependencies added to `implementation` configuration will be picked up by Shadow plugin
and added to the resulting jar for our extension's distribution.
*/
implementation 'org.apache.commons:commons-lang3:3.12.0'
//All dependencies below are only for tests
testImplementation("org.testcontainers:testcontainers:1.17.6")
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
testImplementation("com.google.protobuf:protobuf-java-util:3.22.2")
testImplementation("com.squareup.okhttp3:okhttp:4.10.0")
testImplementation("io.opentelemetry:opentelemetry-api")
testImplementation("io.opentelemetry.proto:opentelemetry-proto:0.19.0-alpha")
testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
testRuntimeOnly("ch.qos.logback:logback-classic:1.4.6")
//Otel Java instrumentation that we use and extend during integration tests
otel("io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}")
//TODO remove when start using io.opentelemetry.instrumentation.javaagent-instrumentation plugin
add("codegen", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions.opentelemetryJavaagentAlpha}")
add("muzzleBootstrap", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support:${versions.opentelemetryJavaagentAlpha}")
add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${versions.opentelemetryJavaagentAlpha}")
add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions.opentelemetryJavaagentAlpha}")
}
//Produces a copy of upstream javaagent with this extension jar included inside it
//The location of extension directory inside agent jar is hard-coded in the agent source code
task extendedAgent(type: Jar) {
dependsOn(configurations.otel)
archiveFileName = "opentelemetry-javaagent.jar"
from zipTree(configurations.otel.singleFile)
from(tasks.shadowJar.archiveFile) {
into "extensions"
}
//Preserve MANIFEST.MF file from the upstream javaagent
doFirst {
manifest.from(
zipTree(configurations.otel.singleFile).matching {
include 'META-INF/MANIFEST.MF'
}.singleFile
)
}
}
tasks {
test {
useJUnitPlatform()
inputs.files(layout.files(tasks.shadowJar))
inputs.files(layout.files(tasks.extendedAgent))
systemProperty 'io.opentelemetry.smoketest.agentPath', configurations.otel.singleFile.absolutePath
systemProperty 'io.opentelemetry.smoketest.extendedAgentPath', tasks.extendedAgent.archiveFile.get().asFile.absolutePath
systemProperty 'io.opentelemetry.smoketest.extensionPath', tasks.shadowJar.archiveFile.get().asFile.absolutePath
}
compileJava {
options.release.set(8)
}
assemble.dependsOn(shadowJar)
}
muzzle {
pass {
group.set("javax.servlet")
module.set("javax.servlet-api")
versions.set("[3.0,)")
assertInverse.set(true)
}
pass {
group.set("javax.servlet")
module.set("servlet-api")
versions.set("[2.2, 3.0)")
assertInverse.set(true)
}
}