JsonExporterOpentelemetryJavaAgent
No description available
Install / Use
/learn @EkaterinaJavaDev/JsonExporterOpentelemetryJavaAgentREADME
Custom Traces, Metrics, and Logs Exporter Documentation
This is a custom exporter for sending data (traces, metrics, and logs) collected by opentelemetry-javaagent in JSON format.
How to Use the Custom Exporter
-
📥 Download Latest Release
-
Specify Paths to the Files
Save the files anywhere in your project and specify their paths when running the application.
Use the following JVM arguments to point to the correct locations:
-javaagent:<path_to>/opentelemetry-javaagent.jar -Dotel.javaagent.extensions=<path_to>/CustomTracesMetricsLogsExporter-0.0.1.jar -Dmetric.interval.minutes=<interval_in_minutes> # Optional: Specify metric collection interval in minutes (default is 30)For example, if you place both files in the root of your project, use:
-javaagent:./opentelemetry-javaagent.jar -Dotel.javaagent.extensions=./CustomTracesMetricsLogsExporter-0.0.1.jar -Dmetric.interval.minutes=15 -
Set JVM Arguments
-
When running your application, add the following JVM arguments to specify where to send traces, logs, and metrics:
-Dspans.destination.url=<traces_url> -Dlogs.destination.url=<logs_url> -Dmetrics.destination.url=<metrics_url> -
By default, the exporter sends data to these URLs:
- Traces:
http://localhost:24224 - Logs:
http://localhost:24225 - Metrics:
http://localhost:24226
- Traces:
-
-
Disable Default Exporters
-
To prevent the agent from sending data to its default ports, disable the default exporters:
-Dotel.traces.exporter=none -Dotel.metrics.exporter=none -Dotel.logs.exporter=none
-
Example in a Dockerfile
Here is how you can set it up in a Dockerfile:
FROM maven AS build
WORKDIR /app
COPY . .
RUN mvn clean package -DskipTests
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app1
COPY --from=build /app/target/your_application.jar your_application.jar
COPY ./opentelemetry-javaagent.jar .
COPY ./CustomTracesMetricsLogsExporter.jar .
EXPOSE 8080
ENTRYPOINT ["java", \
"-javaagent:./opentelemetry-javaagent.jar", \
"-Dotel.javaagent.extensions=./CustomTracesMetricsLogsExporter-0.0.1.jar", \
"-Dotel.traces.exporter=none", \
"-Dotel.metrics.exporter=none", \
"-Dotel.logs.exporter=none", \
"-Djava.security.egd=file:/dev/./urandom", \
"-Dspans.destination.url=https://192.168.0.1:24224", \
"-Dlogs.destination.url=https://192.168.0.1:24225", \
"-Dmetrics.destination.url=https://192.168.0.1:24226", \
"-Dmetric.interval.minutes=20", \
"-jar", "your_application.jar"]
Replace your_application.jar with the name of your application.
Make sure the URLs you provide are correct and the servers are ready to receive the data.
Languages
Security Score
Audited on Feb 11, 2025
