Skip to content

btraceio/btrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e5d1649 · Feb 15, 2025
Jan 21, 2025
Jul 23, 2023
Dec 1, 2024
Aug 16, 2024
Nov 11, 2024
Dec 1, 2024
Nov 9, 2024
Feb 11, 2023
Nov 11, 2024
Nov 11, 2024
Nov 11, 2024
Oct 11, 2021
Oct 11, 2021
Aug 16, 2024
Aug 16, 2024
Nov 9, 2024
Nov 11, 2024
Nov 11, 2024
Nov 9, 2024
Feb 15, 2025
Oct 9, 2016
Oct 9, 2016
Feb 11, 2023
Jul 20, 2023
Feb 5, 2024
Feb 5, 2024
Dec 18, 2020
Oct 9, 2022
Feb 15, 2025

Repository files navigation

Dev build Download codecov.io huhu Join the chat at https://gitter.im/jbachorik/btrace Project Stats

btrace

A safe, dynamic tracing tool for the Java platform

Quick Summary

BTrace is a safe, dynamic tracing tool for the Java platform.

BTrace can be used to dynamically trace a running Java program (similar to DTrace for OpenSolaris applications and OS). BTrace dynamically instruments the classes of the target application to inject tracing code ("bytecode tracing").

Credits

Building BTrace

Setup

You will need the following applications installed

  • Git
  • (optionally, the default launcher is the bundled gradlew wrapper) Gradle

Build

Gradle

cd <btrace>
./gradlew :btrace-dist:build

The binary dist packages can be found in <btrace>/btrace-dist/build/distributions as the *.tar.gz, *.zip, *.rpm and *.deb files. The exploded binary folder which can be used right away is located at <btrace>/btrace-dist/build/resources/main which serves as the BTRACE_HOME location.

Golden Files

Some of the instrumentor related tests are using golden files. Therefore, it is necessary to update those files when the injected code is changed. This can be done with the help of passing in updateTestData Gradle property. Eg. running the tests like ./gradlew test -PupdateTestData will regenerate all golden files which then must be checked in to the Git repository.

Using BTrace

Installation

Download a distribution file from the release page. Explode the binary distribution file (either *.tar.gz or *.zip) to a directory of your choice.

You may set the system environment variable BTRACE_HOME to point to the directory containing the exploded distribution.

You may enhance the system environment variable PATH with $BTRACE_HOME/bin for your convenience.

Or, alternatively, you may install one of the *.rpm or *.deb packages

Running

  • <btrace>/bin/btrace <PID> <trace_script> will attach to the java application with the given PID and compile and submit the trace script
  • <btrace>/bin/btracec <trace_script> will compile the provided trace script
  • <btrace>/bin/btracer <compiled_script> <args to launch a java app> will start the specified java application with the btrace agent running and the script previously compiled by btracec loaded

For the detailed user guide, please, check the Wiki.

Maven Integration

The maven plugin is providing easy compilation of BTrace scripts as a part of the build process. As a bonus you can utilize the BTrace Project Archetype to bootstrap developing BTrace scripts.

Contributing - !!! Important !!!

Pull requests can be accepted only from the signers of Oracle Contributor Agreement