* Option to disable the creation of spans per mojo goal execution * Better documentation * Small doc tweak * Use config param `OTEL_INSTRUMENTATION_MAVEN_MOJOS_ENABLED` instead of `OTEL_MAVEN_INSTRUMENTATION_MOJOS_ENABLED` * config param: `maven.mojo` / `MAVEN_MOJO` rather than `maven.mojos` / `MAVEN_MOJOS` Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com> |
||
|---|---|---|
| .. | ||
| docs/images | ||
| src | ||
| README.md | ||
| build.gradle.kts | ||
README.md
Maven OpenTelemetry extension
Maven extension to observe Maven builds as distributed traces.
Getting Started
The Maven OpenTelemetry Extension is configured using environment variables or JVM system properties and can be added to a build using one of the following ways:
- adding the extension jar to
${maven.home}/lib/ext - adding the path to the extension jar to
-Dmaven.ext.class.path, - adding the extension as a build extension in the
pom.xml, - (since Maven 3.3.1) configuring the extension in
.mvn/extensions.xml.
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=.
mvn dependency:copy -Dartifact=io.opentelemetry.contrib:opentelemetry-maven-extension:1.6.0-alpha
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
mvn -Dmaven.ext.class.path=target/dependency/opentelemetry-maven-extension-1.6.0-alpha.jar verify
Declaring the extension in the pom.xml file
⚠️ Declaring the OpenTelemetry Maven Extension as an
<extension>is broken waiting to fix Failure using the Otel Maven extension declared as an in pom.xml because the pom.xml of the Otel Maven extension lists dependencies even though they are bundled #86.Waiting for this fix, the workaround is to use the OpenTelemetry Maven Extension with
-Dmaven.ext.class.path=target/dependency/opentelemetry-maven-extension.jar
Add the Maven OpenTelemetry Extension in the pom.xml file:
<project>
...
<build>
<extensions>
<extension>
<groupId>io.opentelemetry.contrib</groupId>
<artifactId>opentelemetry-maven-extension</artifactId>
<version>1.6.0-alpha</version>
</extension>
</extensions>
</build>
</project>
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
mvn verify
Configuration
The Maven OpenTelemetry Extension supports a subset of the OpenTelemetry auto configuration environment variables and JVM system properties.
| System property | Environment variable | Description |
|---|---|---|
| otel.exporter.otlp.endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | The OTLP traces and metrics endpoint to connect to. Must be a URL with a scheme of either http or https based on the use of TLS. Example http://localhost:4317. |
| otel.exporter.otlp.headers | OTEL_EXPORTER_OTLP_HEADERS | Key-value pairs separated by commas to pass as request headers on OTLP trace and metrics requests. |
| otel.exporter.otlp.timeout | OTEL_EXPORTER_OTLP_TIMEOUT | The maximum waiting time, in milliseconds, allowed to send each OTLP trace and metric batch. Default is 10000. |
| otel.resource.attributes | OTEL_RESOURCE_ATTRIBUTES | Specify resource attributes in the following format: key1=val1,key2=val2,key3=val3 |
| otel.instrumentation.maven.mojo.enabled | OTEL_INSTRUMENTATION_MAVEN_MOJO_ENABLED | Whether to create spans for mojo goal executions, true or false. Can be configured to reduce the number of spans created for large builds. Default value: true |
ℹ️ The service.name is set by default to maven, it can be overwritten specifying resource attributes.
Examples
Example of a trace of a Maven build.
Example of a distributed trace of a Jenkins pipeline executing a Maven build
Distributed trace of a Jenkins pipeline invoking a Maven build instrumented with the Jenkins OpenTelemetry plugin and the OpenTelemetry Maven Extension and visualized with Jaeger Tracing
Other CI/CD Tools supporting OpenTelemetry traces
List of other CI/CD tools that support OpenTelemetry traces and integrate with the Maven OpenTelemetry Extension creating a distributed traces providing end to end visibility.
Jenkins OpenTelemetry Plugin
The Jenkins OpenTelemetry Plugin exposes Jenkins pipelines & jobs as OpenTelemetry traces and exposes Jenkins health indicators as OpenTelemetry metrics.
Otel CLI
The otel-cli is a command line wrapper to observe the execution of a shell command as an OpenTelemetry trace.

