About this project

BTrace dynamically instruments running Java applications, injecting tracing code at runtime so you can observe behavior without restarting or recompiling the target. The project emphasizes production safety: scripts are verified, and the README states verified scripts cannot crash the application. Overhead is described as low, achieved through bytecode injection. Supported runtimes: BTrace 3.0 runs on Java 8–25+, with running against JVMs older than Java 17 deprecated (still functional in 3.x with a warning; planned removal in 4.0). A migration guide covers upgrading from 2.x. Capabilities highlighted in the README: - Probes for method entry/exit, timings, field access and allocations. - Method timing, exception tracking, and custom probes written as annotated Java classes (e.g. @OnMethod with @Self and @Duration parameters). - DTrace-style oneliners for quick debugging: locations (@entry, @return, @error), actions (print, count, time, stack), filters (duration thresholds, argument comparisons), and wildcard or regex class/method patterns. Installation and packaging options include JBang (recommended, zero-install with a published catalog), SDKMan, manual binary archives, RPM/DEB packages, and Docker images (Debian, Alpine, Distroless variants). A fat agent JAR build supports single-JAR deployment for environments like Spark, Hadoop and Kubernetes, with a Gradle plugin (io.btrace.fat-agent) for embedding selected extensions. A Maven script-compilation plugin lives in a separate repository. Extensions add functionality through a stable bootstrap API with isolated implementations. The legacy libs/profiles mechanism has been removed; integrations should be packaged as extensions. A permission model distinguishes default permissions (MESSAGING, AGGREGATION, JFR_EVENTS, PROFILING), standard permissions (FILE_READ, SYSTEM_PROPS, THREAD_INFO, MEMORY_INFO) and privileged permissions (FILE_WRITE, NETWORK, THREADS, NATIVE, EXEC, REFLECTION, CLASSLOADER, UNLIMITED_MEMORY). Privileged grants are set via agent options or a policy file; allow/deny lists control extension linking, and blocked implementations fall back to SHIMs so probes continue safely. The btracex CLI inspects and manages extensions and policy, including an interactive terminal UI for browsing and toggling allow/deny state. Documentation includes a quick reference, getting-started tutorial, full tutorial, oneliner guide, extension development guide and a documentation hub. Community channels are Slack, Gitter and GitHub Issues. Contributions require signing the Oracle Contributor Agreement. Licensed under Apache 2.0; built with ASM, JCTools and hppcrt.