Skip to main content

Instrumentation

Java Instrumentation - Virex Docs

Instrument Java applications using the TraceFlow OpenTelemetry agent for automatic bytecode injection.

TraceFlow provides a zero-code instrumentation path for Java applications using our OpenTelemetry-based agent. This allows you to capture traces, JVM metrics, and logs without modifying your source code.

Quick Start

  1. Download the Agent — Get the latest traceflow-javaagent.jar.
  2. Attach the Agent — Use the -javaagent JVM argument.
  3. Configure Endpoint — Point the agent to your TraceFlow ingest URL.

Configuration

Add the following flags to your application startup command:

java -javaagent:path/to/traceflow-javaagent.jar \
     -Dotel.service.name=inventory-service \
     -Dotel.exporter.otlp.endpoint=[http://ingest.traceflow.com:4317](http://ingest.traceflow.com:4317) \
     -Dotel.logs.exporter=otlp \
     -jar your-app.jar

Supported Frameworks The Java agent automatically instruments dozens of libraries, including:

Web: Spring Boot, Jakarta EE, Quarkus, Vert.x

Clients: OkHttp, Apache HttpClient, gRPC

Databases: JDBC (MySQL, Postgres, Oracle), MongoDB, Cassandra

Messaging: Kafka, RabbitMQ, JMS

JVM Metrics Collection By default, the agent collects critical JVM telemetry: | Metric | Description | |--------|-------------| | process.runtime.jvm.memory.usage | Heap and non-heap memory consumption | | process.runtime.jvm.gc.duration | Garbage collection pause times | | process.runtime.jvm.threads.count | Active thread count |

Customizing Spans If you need deeper visibility, use the @WithSpan annotation:

Java

import io.opentelemetry.instrumentation.annotations.WithSpan;

public class PaymentService { @WithSpan(“process_payment”) public void process() { // Logic here } }