Git
Read, search and manipulate Git repositories: status, diff, log, commit, branch and more
MOmodelcontextprotocol/servers92k200 new stars in the last 7 days
Trace a running JVM in one line: no restart, nothing left behind. Production-safe dynamic tracing for Java 8–27, with an MCP server for coding agents.
Trace a running JVM in one line. No restart, nothing left behind.
jbang io.btrace:btrace:3.0.0-RC1 -n 'com.myapp.**::* @return if duration>100ms { print method, duration }' $(pgrep -f myapp)
That attaches to the live JVM and prints every method in com.myapp slower than 100 ms. Press Ctrl-C and
the probe is removed and the original bytecode restored. No agent flag at startup, no script file, no restart.
Quick links: Project site · Quick Reference · Step-by-Step Tutorial
this, field access, allocations, and filters on any of them.BTrace 3.0 runs on Java 8–27+. Running BTrace against a JVM older than Java 17 is deprecated: it continues to work throughout 3.x but emits a deprecation warning. Support for Java < 17 will be removed in the next major release (4.0). See the migration guide for details on upgrading from BTrace 2.x and the 3.0.0 release notes for everything that changed.
# Install JBang (one time)
curl -Ls https://sh.jbang.dev | bash -s - app setup
# Trace slow methods in your running app (3.0.0-RC1, straight from Maven Central)
jbang io.btrace:btrace:3.0.0-RC1 -n 'com.myapp.**::* @return if duration>100ms { print method, duration }' $(pgrep -f myapp)
3.0 is in release candidate. The current build is
3.0.0-RC1.sdk install btraceand thebtrace@btraceioJBang alias do not point at it, so the commands here pin the version.
Method timing:
btrace -n 'org.postgresql.jdbc.PgStatement::execute* @return { print method, duration }' <PID>
Exception tracking:
btrace -n 'java.lang.Exception::<init> @return { print self, stack(5) }' <PID>
Custom probes:
@BTrace public class Trace {
@OnMethod(clazz = "com.example.OrderService", method = "checkout",
location = @Location(Kind.RETURN))
public static void onCheckout(@Self Object self, @Duration long ns) {
println("checkout: " + str(ns / 1_000_000) + "ms");
}
}
See the Oneliner Guide for complete syntax.
The 30-second path above needs nothing else. Alternatives:
# JBang by Maven coordinate (no catalog needed, version pinned)
jbang io.btrace:btrace:3.0.0-RC1 <PID> script.java
# Manual download (assets are versioned: btrace-v<version>-bin.tar.gz)
BTRACE_VERSION=3.0.0-RC1
curl -LO https://github.com/btraceio/btrace/releases/download/v${BTRACE_VERSION}/btrace-v${BTRACE_VERSION}-bin.tar.gz
# Docker: copy /opt/btrace from a version-pinned image into your own
# FROM ghcr.io/btraceio/btrace:3.0.0-RC1 AS btrace
# SDKMan (installs 2.2.6 until 3.0.0 is released)
sdk install btrace
With an installed distribution the commands are btrace <PID> <script.java> (attach), btracec <script.java> (compile) and btracer <script.class> <java-args> (launch with the agent; <java-args> is what you would pass to java, without the word java).
Details for every option live in one place each:
-javaagent| Resource | Description |
|---|---|
| Project site | Overview of BTrace 3.0: one-line probes, coding-agent workflows, AI observability |
| Quick Reference | Cheat sheet for experienced users |
| Getting Started | Step-by-step first trace tutorial |
| Full Tutorial | Complete walkthrough of all features |
| Oneliners | DTrace-style quick probes |
| Extensions | StatsD, custom integrations |
| Documentation Hub | All docs and guides |
| Wiki | External wiki with additional resources |
Extensions add functionality via a stable API on bootstrap and an isolated implementation. See the extension development guide and examples.
Note: The legacy libs/profiles mechanism has been removed. The libs=<profile> argument is ignored like any unknown argument and loads nothing, so custom classes that used to arrive that way will no longer resolve. Package integrations as extensions and use provided-style class loading patterns (object hand-off + TCCL). For migration guidance and examples, see:
docs/architecture/migrating-from-libs-profiles.mddocs/architecture/provided-style-extensions.mddocs/examples/README.mdAs a last resort (discouraged), you may append a single jar to the system classpath: set -Dbtrace.system.appendJar=/abs/path/lib.jar on the target JVM together with the trusted=true agent argument (-javaagent:btrace.jar=trusted=true,...); the -Dbtrace.trusted system property has no effect and the agent ignores the jar without the agent argument. In both cases the agent logs a warning that names the trusted=true agent argument.
For environments where managing multiple JARs is impractical (Spark, Hadoop, Kubernetes), BTrace provides a fat agent JAR with embedded extensions:
# Build fat agent with the default extensions
./gradlew :btrace-dist:fatAgentJar
# Build with specific extensions only
./gradlew :btrace-dist:fatAgentJar -PembedExtensions=btrace-metrics,btrace-statsd
# Use the fat agent
java -javaagent:btrace-agent-fat.jar <your-app>
The fat agent JAR includes:
For custom fat agent builds, use the Gradle plugin:
plugins {
id 'io.btrace.fat-agent'
}
btraceFatAgent {
embedExtensions {
// BTrace bundles extension packages in its distribution's extensions/ directory.
file('/path/to/btrace-metrics-3.0.0-extension.zip')
project(':my-custom-extension')
}
}
See Fat Agent Plugin Architecture and Gradle Plugin README for details.
BTrace supports extensions (like the bundled StatsD extension) that provide additional functionality. Extensions require explicit permissions for security:
Permissions are declared in extension descriptors; whether an extension may link is decided by the target JVM's agent options and permission policy file.
An extension that declares a privileged permission links only when the operator allows it via agent options (there is no client-side flag), e.g. when starting the target with the agent:
java -javaagent:btrace.jar=allowExtensions=btrace-metrics ... MainClass
or persistently via a policy file (see PermissionPolicy). The older grant=/deny=/grantAll= agent arguments are accepted but have no effect.
If extensions fail to load, use -le to troubleshoot:
btrace -le <PID>
See the Tutorial for detailed documentation.
Extensions CLI: use btracex to inspect and manage extensions and the simplified permission policy:
btracex inspect <zip|dir> prints extension id, version, services, and whether it’s privileged.btracex policy print|set [--policy-file <path>|--home|--classpath <outDir>] edits allowExtensions, denyExtensions, allowPrivileged.btracex list shows installed extensions; btracex install accepts a local extension package or
Maven coordinates. BTrace-built packages are supplied in the distribution's extensions/
directory and are also published to Maven Central as io.btrace:<extension-id>:<version>.Note: Extension “required permissions” are informational and help operators assess risk. Implementation linking is controlled by per‑extension allow/deny lists and the allowPrivileged flag. When an extension is blocked, a plain @Injected field fails the probe deployment fast; only @Injected(optional = true) falls back, and the fallback is a throwing stub by default (mode = SHIM or -Dbtrace.extension.shimMode=shim selects a no-op shim).
-javaagent:btrace.jar=...,allowExtensions=btrace-statsd,my-metrics,denyExtensions=legacy-foo-javaagent:btrace.jar=...,allowPrivileged=true (every privileged extension; use with caution)-Dbtrace.permissions=/path/to/permissions.properties or ~/.btrace/permissions.properties.@Injected(optional = true) fields can be bound to a shim or throwing stub; non-optional fields fail the probe fast.See docs/PermissionPolicy.md for details and examples.
btracex inspect (with no args) opens an interactive view of installed extensions.? (default), + (allowed), - (denied).default / allowed / denied and the full path.The TUI provides a keyboard-driven, terminal-based view for browsing installed extensions and toggling their allow/deny state without editing the policy file by hand.
Keys
? → + (confirm) → - → +; only c clears to default)c (removes extension id from both allow and deny lists)e (opens a dialog with required permissions and risk descriptions)/ (filter by id or path)s (choose column; repeat to toggle asc/desc)m (enter mode), then Up/Down to resize; press Esc or m again to exit? / qFat Agent Plugin: The unpublished in-repository Maven fat-agent module was removed for 3.0.0
because it cannot consume the published 3.0 extension layout safely. Use the
io.btrace.fat-agent Gradle plugin documented above.
Script Compilation Plugin (external repo):
BTrace sends no telemetry unless you opt in. The default agent start performs no network operation
and creates no telemetry thread; only the explicit telemetry=true agent argument enables a single
agent_start event. See Getting Started: Optional agent telemetry
for what is sent and how to disable it again.
git clone https://github.com/btraceio/btrace.git
cd btrace
./gradlew :btrace-dist:build
See CONTRIBUTING.md for development setup (required JDK toolchains, running tests) and docs/README.md for architecture.
Tips:
GRADLE_OPTS="-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false"../gradlew :btrace-runtime:test./gradlew :btrace-core:test./gradlew :btrace-compiler:test./gradlew :btrace-agent:test./gradlew test -PupdateTestData.Integration tests (optional; without -Pintegration the task is skipped and runs nothing):
./gradlew --no-daemon -Pintegration :integration-tests:test
Misuse-resilience QE (optional):
./gradlew :btrace-qe:qe
Runs the abuse corpus in btrace-qe/cases/ against real JVMs and writes a findings report to btrace-qe/build/qe-report/. See the QE Agent guide. Every abuse idea explored so far (kept, rejected, blocked, open leads) is logged in btrace-qe/EXPLORATION.md; check it before proposing new cases.
Contributions are accepted under the Apache License 2.0. See CONTRIBUTING.md for the workflow and expectations, and AGENTS.md for the rules coding agents follow.
Apache License 2.0. See LICENSE.
Credits: Built with ASM, JCTools, hppcrt. Optimized with JProfiler.
Read, search and manipulate Git repositories: status, diff, log, commit, branch and more
MOmodelcontextprotocol/servers92k200 new stars in the last 7 days
Compress tool outputs, logs and files, cutting tokens by 20%-95% without changing answers.
HEheadroomlabs-ai/headroom81k538 new stars in the last 7 days
Index a codebase into a persistent knowledge graph and query its structure with far fewer tokens.
DEDeusData/codebase-memory-mcp49k309 new stars in the last 7 days
Manage repos, issues and PRs, analyze code and CI/CD workflows using natural language.
GIgithub/github-mcp-server35k181 new stars in the last 7 days
Retrieve code semantically, edit, refactor and debug at the symbol level.
ORoraios/serena32k209 new stars in the last 7 days
Compile code with thousands of compilers, inspect the assembly, and share godbolt.org links
COcompiler-explorer/compiler-explorer19k7 new stars in the last 7 days