Skip to content

Commit a7b01db

Browse files
committed
setup project
1 parent 2fb6034 commit a7b01db

File tree

7 files changed

+96
-71
lines changed

7 files changed

+96
-71
lines changed

.github/scripts/update-sdk-version.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash -e
2+
# script to update the OpenTelemetry SDK version
3+
4+
# version, which should be used for the SDK
5+
version=$1
6+
7+
sed -Ei "s/(opentelemetrySdk *: )\"[^\"]*\"/\1\"$version\"/" build.gradle

.github/scripts/update-version.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash -e
2+
# script to update the OpenTelemetry Java agent version
3+
4+
5+
# version, which should be used for the java agent
6+
version=$1
7+
8+
if [[ $version == *-SNAPSHOT ]]; then
9+
alpha_version=${version//-SNAPSHOT/-alpha-SNAPSHOT}
10+
else
11+
alpha_version=${version}-alpha
12+
fi
13+
14+
sed -Ei "s/(opentelemetryJavaagent *: )\"[^\"]*\"/\1\"$version\"/" build.gradle
15+
sed -Ei "s/(opentelemetryJavaagentAlpha *: )\"[^\"]*\"/\1\"$alpha_version\"/" build.gradle
16+
17+
sed -Ei "s/(io.opentelemetry.instrumentation.muzzle-generation\" version )\"[^\"]*\"/\1\"$alpha_version\"/" build.gradle
18+
sed -Ei "s/(io.opentelemetry.instrumentation.muzzle-check\" version )\"[^\"]*\"/\1\"$alpha_version\"/" build.gradle

.github/workflows/ci-feature.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ name: Feature Branch Continous Integration
22

33
on:
44
push:
5-
branches: [ "feature/**" ]
6-
5+
branches:
6+
- "feature/**"
7+
- master
8+
pull_request:
9+
710
jobs:
811
build-and-test:
12+
name: "Build and test extension"
913
runs-on: ubuntu-latest
1014
permissions:
1115
contents: read
@@ -27,19 +31,17 @@ jobs:
2731

2832
- name: Build
2933
run: ./gradlew extendAgent
30-
34+
3135
- name: Upload build artifacts
3236
uses: actions/upload-artifact@v4
3337
with:
3438
name: Package
3539
path: build/libs
36-
37-
dependency-submission:
3840

41+
dependency-submission:
3942
runs-on: ubuntu-latest
4043
permissions:
4144
contents: write
42-
4345
steps:
4446
- uses: actions/checkout@v4
4547
- name: Set up JDK 17

README.md

+3-30
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
1-
# Extension
2-
This extension is used as a showcase for VHV in order to demonstrate that we can move inspectit's
3-
agent logic to opentelemetry agent enhanced via an extension.
4-
5-
Use `./gradlew extendAgent` (no tests) or `./gradlew build` to build an agent jar with your current
1+
# inspectIT Gepard Extension
2+
Extension for the OpenTelemetry Java agent.
3+
Use `./gradlew extendedAgent` (no tests) or `./gradlew build` to build an agent jar with your current
64
changes.
75

8-
## TODOs / next steps
9-
* otel agent wants to export spans.
10-
* Find out where otel wants to report spans to. Jaeger? Something else?
11-
* Do we want to use that? Do we want to disable it?
12-
* Is it easy to change it to an url provided by the config server?
13-
* this extension sends an additional http header named `X-OCELOT-AGENT-TYPE` to the config server. Use it over there to display a different icon in the config server's UI
14-
* tests do not work
15-
* Probably not that important
16-
17-
# Documentation
18-
This extension calls the agent configuration endpoint of the configuration server. For your local
19-
installation this is typically available at http://localhost:8090/v1/api/agent/configuration. The
20-
endpoint of the server is defined in class `rocks.inspectit.ocelot.rest.agent.AgentController` of inspectit-ocelot.
21-
22-
Calling that endpoint serves the following purposes:
23-
* First call registers Agent with configuration server
24-
* uses query parameter `service` to display something meaningful in the UI. Currently, hardcoded to `otel-extension`
25-
* Regularly polls configuration server to fetch potentially updated configurations
26-
* Transmits by each call the health state of the agent
27-
* Send an `X-OCELOT-AGENT-TYPE` to distinguish inspectit-ocelot-agent and this agent
28-
29-
Currently, you can influence the target url via SystemProperty named `inspectit.config.http.url`.
30-
31-
Polling of configuration is handled in classes `ConfigurationPolling` and `HttpConfiguration`.
32-
336
# Original Readme
347
The following is the original content from which this work is derived.
358
Source: https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/examples/extension

build.gradle

+32-34
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,35 @@ plugins {
1111
See https://imperceptiblethoughts.com/shadow/ for more details about Shadow plugin.
1212
*/
1313
id "com.github.johnrengelman.shadow" version "8.1.1"
14-
id "com.diffplug.spotless" version "6.17.0"
14+
id "com.diffplug.spotless" version "6.25.0"
1515

16-
id "io.opentelemetry.instrumentation.muzzle-generation" version "1.31.0-alpha"
17-
id "io.opentelemetry.instrumentation.muzzle-check" version "1.31.0-alpha"
16+
id "io.opentelemetry.instrumentation.muzzle-generation" version "2.5.0-alpha"
17+
id "io.opentelemetry.instrumentation.muzzle-check" version "2.5.0-alpha"
1818

19-
id "pl.allegro.tech.build.axion-release" version "1.11.0"
19+
id "pl.allegro.tech.build.axion-release" version "1.17.2"
2020

2121
}
2222

2323
group 'rocks.inspectit.gepard.agent'
24-
version = scmVersion.version
24+
version = "0.0.1-SNAPSHOT"
2525

2626
sourceCompatibility = "17"
2727
targetCompatibility = "17"
2828

2929
ext {
3030
versions = [
3131
// this line is managed by .github/scripts/update-sdk-version.sh
32-
opentelemetrySdk : "1.38.0",
32+
opentelemetrySdk : "1.39.0",
3333

3434
// these lines are managed by .github/scripts/update-version.sh
35-
opentelemetryJavaagent : "2.3.0",
36-
opentelemetryJavaagentAlpha: "2.3.0-alpha",
35+
opentelemetryJavaagent : "2.5.0",
36+
opentelemetryJavaagentAlpha: "2.5.0-alpha",
3737

38-
junit : "5.9.2"
38+
junit : "5.10.2"
3939
]
4040

4141
deps = [
42-
autoservice: dependencies.create(group: 'com.google.auto.service', name: 'auto-service', version: '1.0.1')
42+
autoservice: dependencies.create(group: 'com.google.auto.service', name: 'auto-service', version: '1.1.1')
4343
]
4444
}
4545

@@ -73,13 +73,11 @@ dependencies {
7373
// these serve as a test of the instrumentation boms
7474
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:${versions.opentelemetryJavaagent}"))
7575
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${versions.opentelemetryJavaagentAlpha}"))
76-
implementation("org.apache.httpcomponents:httpclient:4.5.14")
77-
implementation("commons-codec:commons-codec:1.15")
78-
implementation("ch.qos.logback:logback-classic:1.3.6")
79-
implementation("org.slf4j:jcl-over-slf4j:2.0.4")
8076

81-
// For instrumentation, same version as OpenTelemetry
82-
implementation("net.bytebuddy:byte-buddy:1.14.12")
77+
// inspectit-gepard dependencies
78+
implementation("net.bytebuddy:byte-buddy:1.14.15")
79+
implementation("ch.qos.logback:logback-classic:1.5.6")
80+
implementation("org.slf4j:jcl-over-slf4j:2.0.13")
8381

8482
/*
8583
Interfaces and SPIs that we implement. We use `compileOnly` dependency because during
@@ -90,35 +88,35 @@ dependencies {
9088
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
9189
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
9290
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap")
93-
//Provides @AutoService annotation that makes registration of our SPI implementations much easier
91+
92+
// Provides @AutoService annotation that makes registration of our SPI implementations much easier
9493
compileOnly deps.autoservice
9594
annotationProcessor deps.autoservice
9695

97-
98-
//All dependencies below are only for tests
99-
testImplementation("org.testcontainers:testcontainers:1.17.6")
100-
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
101-
testImplementation("com.google.protobuf:protobuf-java-util:3.22.2")
102-
testImplementation("com.squareup.okhttp3:okhttp:4.10.0")
96+
// All dependencies below are only for tests
97+
testImplementation("org.testcontainers:testcontainers:1.19.8")
98+
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.17.1")
99+
testImplementation("com.google.protobuf:protobuf-java-util:3.25.3")
100+
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
103101
testImplementation("io.opentelemetry:opentelemetry-api")
104-
testImplementation("io.opentelemetry.proto:opentelemetry-proto:0.19.0-alpha")
102+
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.3.1-alpha")
105103

106104
testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
107105
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
108-
testRuntimeOnly("ch.qos.logback:logback-classic:1.4.6")
106+
testRuntimeOnly('ch.qos.logback:logback-classic:1.5.6')
109107

110-
//Otel Java instrumentation that we use and extend during integration tests
108+
// Otel Java instrumentation that we use and extend during integration tests
111109
otel("io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}")
112110

113-
//TODO remove when start using io.opentelemetry.instrumentation.javaagent-instrumentation plugin
111+
// TODO remove when start using io.opentelemetry.instrumentation.javaagent-instrumentation plugin
114112
add("codegen", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions.opentelemetryJavaagentAlpha}")
115113
add("muzzleBootstrap", "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations-support:${versions.opentelemetryJavaagentAlpha}")
116114
add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${versions.opentelemetryJavaagentAlpha}")
117115
add("muzzleTooling", "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions.opentelemetryJavaagentAlpha}")
118116
}
119117

120-
//Produces a copy of upstream javaagent with this extension jar included inside it
121-
//The location of extension directory inside agent jar is hard-coded in the agent source code
118+
// Produces a copy of upstream javaagent with this extension jar included inside it
119+
// The location of extension directory inside agent jar is hard-coded in the agent source code
122120
tasks.register('extendedAgent', Jar) {
123121
dependsOn(configurations.otel)
124122
archiveFileName = "opentelemetry-javaagent.jar"
@@ -127,12 +125,12 @@ tasks.register('extendedAgent', Jar) {
127125
into "extensions"
128126
}
129127

130-
//Preserve MANIFEST.MF file from the upstream javaagent
128+
// Preserve MANIFEST.MF file from the upstream javaagent
131129
doFirst {
132130
manifest.from(
133-
zipTree(configurations.otel.singleFile).matching {
134-
include 'META-INF/MANIFEST.MF'
135-
}.singleFile
131+
zipTree(configurations.otel.singleFile).matching {
132+
include 'META-INF/MANIFEST.MF'
133+
}.singleFile
136134
)
137135
}
138136
}
@@ -150,7 +148,7 @@ tasks {
150148
}
151149

152150
compileJava {
153-
options.release.set(8)
151+
options.release.set(17)
154152
}
155153

156154
assemble.dependsOn(shadowJar)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package rocks.inspectit.gepard.agent;
2+
3+
import com.google.auto.service.AutoService;
4+
import io.opentelemetry.javaagent.tooling.AgentExtension;
5+
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
6+
import net.bytebuddy.agent.builder.AgentBuilder;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
@SuppressWarnings("unused")
11+
@AutoService(AgentExtension.class)
12+
public class InspectitAgentExtension implements AgentExtension {
13+
14+
private static final Logger log = LoggerFactory.getLogger(InspectitAgentExtension.class);
15+
16+
@Override
17+
public AgentBuilder extend(AgentBuilder agentBuilder, ConfigProperties config) {
18+
log.info("Starting inspectIT Gepard agent extension ...");
19+
20+
return agentBuilder;
21+
}
22+
23+
@Override
24+
public String extensionName() {
25+
return "inspectit-gepard";
26+
}
27+
}

0 commit comments

Comments
 (0)