-
Notifications
You must be signed in to change notification settings - Fork 64
/
build.gradle
68 lines (53 loc) · 1.77 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
import org.springframework.boot.gradle.plugin.SpringBootPlugin
plugins {
id 'java'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.springframework.boot' version '3.3.3'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
spotless {
java {
googleJavaFormat()
}
}
repositories {
mavenCentral()
}
configurations {
// Create a new configuration to hold the otel java agent
agent
}
def otelInstrumentationVersion = "2.7.0-alpha";
dependencies {
implementation platform(SpringBootPlugin.BOM_COORDINATES)
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}")
implementation("io.opentelemetry:opentelemetry-api")
// Add OpenTelemetry java agent to the "agent" configuration we previously defined
agent(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}"))
agent("io.opentelemetry.javaagent:opentelemetry-javaagent")
}
tasks.register("copyAgent", Copy) {
from(configurations.agent.singleFile)
into(layout.buildDirectory.dir('agent'))
rename("opentelemetry-javaagent-.*\\.jar", "opentelemetry-javaagent.jar")
}
bootJar {
archiveBaseName.set('getting-started-java')
// Before running, copy the agent to a reliable place in the build dir
dependsOn("copyAgent")
}
bootRun {
// Before running, copy the agent to a reliable place in the build dir
dependsOn("copyAgent")
mainClass.set 'com.example.demo.Application'
def agentPath = project.buildDir.toString() + "/agent/opentelemetry-javaagent.jar"
jvmArgs = [
// Set the opentelemetry-java-instrumentation agent as the javaagent
"-javaagent:${agentPath}"
]
}