Skip to content

[jmx-scraper] Package jmx scraper as a deb/rpm/tar.gz package #1964 #2099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions jmx-scraper/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
plugins {
application
id("com.gradleup.shadow")

id("otel.java-conventions")

id("otel.publish-conventions")
}

Expand Down Expand Up @@ -92,6 +90,39 @@ tasks {
}
}

// This task copies the jar to a package dir for packaging.
val copyJarForPackage by tasks.registering(Copy::class) {
dependsOn(tasks.jar)

// Clean target directory before copying
doFirst {
val targetDir = file("package/usr/local/bin")
if (targetDir.exists()) {
targetDir.deleteRecursively()
}
}

from(tasks.jar.get().outputs.files)
into("package/usr/local/bin")
rename { "jmx-scraper.jar" }
}

// This task creates a tarball of the package directory.
val createTarball by tasks.registering(Tar::class) {
dependsOn(copyJarForPackage)
archiveBaseName.set("opentelemetry-jmx-scraper")
archiveVersion.set(project.version.toString())
archiveExtension.set("tar.gz")
compression = Compression.GZIP
// simply put it at the project root
destinationDirectory.set(file("./"))

from("package") {
// preserve directory structure relative to package/
into("/")
}
}

// Don't publish non-shadowed jar (shadowJar is in shadowRuntimeElements)
with(components["java"] as AdhocComponentWithVariants) {
configurations.forEach {
Expand Down
15 changes: 15 additions & 0 deletions jmx-scraper/package/etc/systemd/jmx-scraper.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=OpenTelemetry JMX Scraper
After=network.target

[Service]
Type=simple
User=jmxscraper
Group=jmxscraper
ExecStart=/usr/bin/java -jar /usr/local/bin/jmx-scraper.jar
Restart=on-failure
RestartSec=10
WorkingDirectory=/usr/local/bin

[Install]
WantedBy=multi-user.target
11 changes: 11 additions & 0 deletions maven-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ The Maven OpenTelemetry Extension is configured using environment variables or J
In the code snippets below, replace `OPENTELEMETRY_MAVEN_VERSION` with the [latest
release](https://search.maven.org/search?q=g:io.opentelemetry.contrib%20AND%20a:opentelemetry-maven-extension).

## Installation
jmx-scraper is typically run as a standalone JAR file.
o use it, you generally need to download the latest JAR from the OpenTelemetry Java Contrib releases page
or retrieve it as a dependency from a Maven repository.
Once obtained, you can run it using the Java command line tool.
Please refer to [Usage](#usage).

For systemd service, the opentelemetry-jmx-scraper-x.xx.x.tar.gz tar.gz file is available
with the JAR and a ready to install systemd service file.


### Adding the extension to the classpath

Add the Maven OpenTelemetry Extension to `${maven.home}/lib/ext` or to the classpath using `-Dmaven.ext.class.path=`.
Expand Down
Loading