-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathbuild.gradle
52 lines (40 loc) · 1.68 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
import org.springframework.boot.gradle.plugin.SpringBootPlugin
plugins {
id 'java-library'
id 'org.springframework.boot'
}
configurations.all {
exclude module: 'spring-boot-starter-logging'
}
configurations {
agent
}
dependencies {
implementation 'io.opentelemetry:opentelemetry-api'
agent(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${project.property('otelInstrumentationVersion')}"))
agent("io.opentelemetry.javaagent:opentelemetry-javaagent")
implementation platform(SpringBootPlugin.BOM_COORDINATES)
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}
tasks.register("copyAgent", Copy) {
from(configurations.agent.singleFile)
into(layout.buildDirectory.dir('agent'))
rename("opentelemetry-javaagent-.*\\.jar", "opentelemetry-javaagent.jar")
}
bootRun {
mainClass.set 'com.newrelic.app.Application'
// Before running, build the config-extension shadow jar
dependsOn(":agent-nr-config:config-extension:shadowJar")
// Before running, copy the agent to a reliable place in the build dir
dependsOn("copyAgent")
def extensionPath = project(":agent-nr-config:config-extension").buildDir.toString() + "/libs/config-extension.jar"
def agentPath = project.buildDir.toString() + "/agent/opentelemetry-javaagent.jar"
jvmArgs = [
// Set the opentelemetry-java-instrumentation agent as the javaagent
"-javaagent:${agentPath}",
// Use the config-extension shadowJar to configure the agent via SPI
"-Dotel.javaagent.extensions=${extensionPath}"
]
}