Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
5b941fe
fix(release): make io.btrace:btrace and the Gradle plugins publishable
claude Nov 16, 2026
d84fae0
docs: correct ops, protocol and release documentation against the code
claude Nov 16, 2026
6de603f
fix(compiler): find bundled extension APIs when BTRACE_HOME is not ex…
claude Nov 16, 2026
5a65f3e
docs: correct troubleshooting, migration and core tutorials against t…
claude Nov 16, 2026
1c1e066
fix(build): declare the sources-jar project reference to the layering…
claude Nov 17, 2026
a8663a2
fix(compiler): honour -Dbtrace.libs and compile numeric oneliner filters
claude Nov 17, 2026
ef0fa24
fix(dist): make btracer -u and btracex list work
claude Nov 17, 2026
e3ff4a0
build(jmh): read the quick-run settings the benchmark workflow passes
claude Nov 17, 2026
ede51d4
fix(agent): load startup probes after extensions and report every fai…
claude Nov 17, 2026
81bc544
fix(security): enforce loops and trusted mode on probes submitted as …
claude Nov 17, 2026
c59ebfc
docs(internal): record the pending btrace.io/btrace corrections
claude Nov 17, 2026
1ee5495
docs: correct user, extension and reference docs against the code
claude Nov 17, 2026
bba6b2a
fix(verifier): reject a handler that calls another handler
claude Nov 17, 2026
7d06fe2
fix(samples): make the three bundled samples that failed to compile b…
claude Nov 17, 2026
38fd273
fix(release): keep the btrace-latest JBang alias on the develop snapshot
claude Nov 17, 2026
939afba
docs(internal): mark the jbang-catalog snapshot-repository fix as app…
claude Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/release-notes/v3.0.0-RC1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
> **Release candidate.** This is the first candidate of BTrace 3.0.0, published so the release
> can be tried before it is final. Report problems at
> https://github.com/btraceio/btrace/issues.
>
> A candidate is published to Maven Central, as this GitHub pre-release (archives, DEB, RPM) and
> as version-tagged container images. It is **not** published to SDKMAN, the `btrace@btraceio`
> JBang catalog alias, or the Gradle Plugin Portal, and the `latest` container tags do not move:
> `sdk install btrace` still installs 2.2.6, and the `io.btrace.extension` and
> `io.btrace.fat-agent` plugin ids resolve only once 3.0.0 is released. The documentation linked
> below is the one tagged with this candidate; where it names version `3.0.0` in a download URL,
> Maven coordinate or image tag, use `3.0.0-RC1`.

BTrace 3.0.0 is the first major release since 2.2.6 (November 2024): a new package namespace, a
new license, a single-jar distribution, an extension framework with permissions, a much shorter
script syntax, a binary wire protocol, and instrumentation that keeps working on class files newer
than the validated ASM ceiling.

Upgrading from 2.x is mostly automatic; read the
[migration guide](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/Migration-2.x-to-3.0.md)
first. Everything below is documented in the
[documentation hub](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/README.md).

## Highlights

- **New home: `io.btrace`.** Sources, Maven coordinates (`io.btrace:btrace`), and the runtime API
moved from `org.openjdk.btrace`. Probes compiled with 2.x keep working: the agent rewrites the
old package references when it loads a persisted probe.
- **Apache License 2.0.** BTrace was GPLv2 with the Classpath Exception.
- **One jar.** `btrace.jar` is the agent, the client, and the boot artifact at once. Its internal
classes are stored as *masked classdata* (renamed resources the JVM does not see as classes), so
ASM, the compiler, and the engine stay invisible to the target application's classpath.
- **Extensions with permissions.** Bundle services into isolated, permission-gated extensions
(`@Injected`), manage them with the new `btracex` CLI, and ship the bundled ones: metrics
(HdrHistogram), StatsD, contracts, LLM tracing, RAG quality, GPU bridge, utilities.
- **Flat DSL and auto-imports.** Scripts no longer need `BTraceUtils.` prefixes or import
boilerplate; `import static io.btrace.BTrace.*` and `import io.btrace.core.annotations.*` are
injected for you.
- **Oneliners.** `btrace -n 'com.acme.*::* @return if duration>100ms { print method, duration }' <pid>`
deploys a probe without writing a file.
- **Binary wire protocol (V2)** is the default, with automatic V1 fallback so 2.x clients and
agents still talk to 3.0 ones on dynamic attach.
- **ClassFile API instrumentation backend.** The bundled ASM handles class files up to the Java 27
class-file version, the agent's validated ASM ceiling. On JDK 24+ agents, classes newer than
that (Java 28 early-access builds today) are instrumented through the JDK's ClassFile API
instead; every probe kind and handler parameter works there.
- **Authenticated prepared mode and `btrace doctor`.** *Prepared mode* is a JVM started with the
agent and no startup script, waiting for a later client connection. `-javaagent:btrace.jar=port=0`
binds a loopback, token-protected endpoint that 3.0 clients discover through the Attach API (a
plain `-javaagent:btrace.jar` does the same on port 2020); `btrace doctor <pid>` reports
readiness before and after attach.
- **Probe budgets.** Whoever launches the JVM can cap what a probe may cost it:
`-Dio.btrace.probeTtl=<seconds>` limits how long a probe stays installed, and
`-Dio.btrace.probeMaxRate=<hits/s>` limits how often its handlers on application code fire
(the `probeTtl=` / `probeMaxRate=` agent arguments do the same at launch). The agent removes a
probe that exceeds a limit and the client exits with code `5` and the reason. A client attaching
later cannot set or raise the limits, and trusted mode is refused while a budget is in effect.
See [Probe budgets](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/GettingStarted.md#probe-budgets).
- **Fat agents and containers.** The `io.btrace.fat-agent` Gradle plugin embeds extensions and
startup probes into a single `-javaagent` jar. Each embedded extension's implementation classes
are isolated under their own `META-INF/btrace-extensions/<id>/` prefix, so extensions that
carry classes of the same name do not clash, and an API class claimed by two extensions fails
the build instead of being dropped; official Docker images
(`ghcr.io/btraceio/btrace:3.0.0-RC1`, `-alpine`, `-distroless`) ship the distribution as a layer.
- **AI-assisted debugging.** The MCP server now lives in the
[`btraceio/agent-plugins`](https://github.com/btraceio/agent-plugins) repository as the
`btrace-observability` plugin.
- **Telemetry is opt-in only** (`telemetry=true` agent argument); the default agent start performs
no network operation.

## Breaking changes

- `org.openjdk.btrace.*` sources must be renamed to `io.btrace.*` (or drop the imports and rely on
auto-imports); `scripts/migrate-btrace-script.sh` does the rewrite. Compiled probes need no change.
- The `btrace-agent.jar` / `btrace-boot.jar` / `btrace-client.jar` layout is gone; point launch
scripts at `libs/btrace.jar`. Maven Central carries `io.btrace:btrace` (the single jar with the
bundled extensions embedded) and each bundled extension as `io.btrace:<extension-id>`; the
`btrace-agent`, `btrace-client`, `btrace-boot`, and `btrace-instr` artifacts are not published.
- Permissions are declared by extensions and granted on the agent side (`allowExtensions=`,
`allowPrivileged=`, or the permission policy file); the client has no `--grant` flag, and the
`grant=` / `deny=` / `grantAll=` agent arguments are accepted but have no effect. (The
probe-level `@RequestPermission(s)` annotations seen in 3.0 pre-release builds were removed
before release and never existed in 2.x.)
- The `Aggregations` API (`Aggregations.newAggregation`, `AggregationFunction`,
`addToAggregation`, `printAggregation`, `clearAggregation`) was removed. Use the bundled
`btrace-metrics` extension for histograms and stats, or plain counters and maps from
`BTraceUtils`.
- `libs=<profile>` and `btrace-libs/` profiles were removed, not deprecated: the agent no
longer recognizes the `libs` argument, ignores it like any unknown argument, and loads nothing.
Migrate to extensions.
- Prepared mode (`-javaagent:btrace.jar=port=...`) now requires authentication before every
command and binds loopback only; a 2.x client cannot connect to a 3.0 prepared endpoint (dynamic
attach remains compatible). Remote prepared-mode operation is not supported in 3.0.0.
- The Maven fat-agent plugin was never published and is not part of 3.0; use the Gradle plugin.

## Deprecated

- **Running BTrace against a JVM older than Java 17.** BTrace 3.0 runs on Java 8–27+, and pre-17
targets keep working throughout 3.x, but the agent and client print a one-time warning. Support
for Java < 17 will be removed in 4.0. Suppress the warning with
`-Dbtrace.suppressJavaDeprecationWarning=true` (on the target JVM for the agent notice, on the
client JVM for the console notice).

## Behavior changes worth knowing

- Probe handlers are dispatched through `invokedynamic` call sites that become no-ops when the
client exits, so retracting a probe leaves no lingering overhead.
- `btrace --version` reports the build commit.

## Install

```sh
jbang io.btrace:btrace:3.0.0-RC1 <pid> ... # JBang, by Maven coordinate
curl -LO https://github.com/btraceio/btrace/releases/download/v3.0.0-RC1/btrace-v3.0.0-RC1-bin.tar.gz
sudo dpkg -i btrace_3.0.0~RC1-1_all.deb # Debian/Ubuntu (release asset)
sudo rpm -i btrace-3.0.0~RC1-1.noarch.rpm # RPM-based (release asset)
docker pull ghcr.io/btraceio/btrace:3.0.0-RC1
```

Maven: `io.btrace:btrace:3.0.0-RC1`; bundled extensions: `io.btrace:<extension-id>:3.0.0-RC1`.

## Learn more

- [Getting started](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/GettingStarted.md)
- [Hands-on tutorials](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/tutorials/README.md)
- [Quick reference](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/QuickReference.md)
- [Migration guide](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/Migration-2.x-to-3.0.md)
- [Masked JAR architecture](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/architecture/MaskedJarArchitecture.md)
- [JDK compatibility](https://github.com/btraceio/btrace/blob/v3.0.0-RC1/docs/JDKCompatibility.md)
5 changes: 3 additions & 2 deletions .github/release-notes/v3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ first. Everything below is documented in the
- `org.openjdk.btrace.*` sources must be renamed to `io.btrace.*` (or drop the imports and rely on
auto-imports); `scripts/migrate-btrace-script.sh` does the rewrite. Compiled probes need no change.
- The `btrace-agent.jar` / `btrace-boot.jar` / `btrace-client.jar` layout is gone; point launch
scripts at `libs/btrace.jar`. Only `io.btrace:btrace` is published to Maven Central; the
`btrace-agent`, `btrace-client`, `btrace-boot`, and `btrace-instr` artifacts are not.
scripts at `libs/btrace.jar`. Maven Central carries `io.btrace:btrace` (the single jar with the
bundled extensions embedded) and each bundled extension as `io.btrace:<extension-id>`; the
`btrace-agent`, `btrace-client`, `btrace-boot`, and `btrace-instr` artifacts are not published.
- Permissions are declared by extensions and granted on the agent side (`allowExtensions=`,
`allowPrivileged=`, or the permission policy file); the client has no `--grant` flag, and the
`grant=` / `deny=` / `grantAll=` agent arguments are accepted but have no effect. (The
Expand Down
49 changes: 29 additions & 20 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ This directory contains GitHub Actions workflows for continuous integration and
- Runs integration tests with `-Pintegration` flag
- **qe:** Runs the `btrace-qe` harness (self tests plus every case surface, including the `demos`
replay of `demos/`) on Java 21 with the Java 24 toolchain
- **publish:** Publishes artifacts to Maven Central
- **gradle-plugin:** Runs the `btrace-gradle-plugin` tests (`../gradlew test` in that directory)
- **guardrails:** Runs the `scripts/guardrails` checks (agent configuration, documented commands and versions, layering, launchers, and the growth and swallow checks)
- **tests-passed:** The single required check; fails unless build, every test lane, qe, guardrails and gradle-plugin succeeded
- **publish:** Publishes snapshot artifacts (`./gradlew -x test :btrace-dist:publish`)
- Only on `develop` branch
- Requires GPG signing credentials
- Skipped with a notice when the GPG signing or Sonatype credentials are not configured
- **cleanup:** Removes temporary artifacts

**Enhancements for V2 Protocol:**
Expand All @@ -55,7 +58,7 @@ protocol subset on every PR.
#### **unit-tests**
- Runs all v2 protocol unit tests on Java 11, 17, 21
- Tests binary serialization/deserialization
- Validates all 17 command types
- Validates all 19 command types
- Upload test reports as artifacts

#### **protocol-negotiation-tests**
Expand All @@ -65,7 +68,7 @@ protocol subset on every PR.
- Verifies magic byte detection

#### **edge-case-tests**
- Runs 35 edge case scenarios
- Runs the 27 edge case tests (`BinaryProtocolEdgeCasesTest`)
- Tests boundary conditions
- Validates large message handling
- Tests compression functionality
Expand All @@ -76,7 +79,8 @@ protocol subset on every PR.
- Triggered by workflow dispatch. The job also tests for `[benchmark]` in `head_commit.message`, but
that field exists only on push events, which this workflow does not handle, so a commit message
cannot trigger it.
- Quick benchmarks: warmup=1, iterations=2, fork=1
- Passes `-Pjmh.warmupIterations=1 -Pjmh.iterations=2 -Pjmh.fork=1`, which `btrace-core/build.gradle`
reads in place of its defaults (warmup=3, iterations=5, fork=2)
- Focuses on serialization performance
- Uploads JMH results for 30 days

Expand Down Expand Up @@ -139,25 +143,32 @@ weekly schedule.
- Waits up to 30 minutes for manual release via Central Portal
- Creates GitHub release only after Maven artifacts are available
- Updates SDKMan and manages milestones
- Release candidates (`release_type: rc`, version `X.Y.Z-RCn`) publish to Maven Central and a GitHub pre-release only; see [Releasing: Release Candidates](../../docs/releasing.md#release-candidates)
- Release candidates (`release_type: rc`, version `X.Y.Z-RCn`) publish to Maven Central, a GitHub pre-release and version-tagged container images only (no `latest` tags, Plugin Portal, JBang catalog or SDKMAN); see [Releasing: Release Candidates](../../docs/releasing.md#release-candidates)

**Manual Checkpoint:** After staging, you must release via [Central Portal](https://central.sonatype.com/publishing/deployments). This allows reviewing artifacts before they become permanent.

### 7. Other workflows

- `pr-metadata.yml` - checks pull request metadata (`scripts/guardrails/check_pr_metadata.py`) when a PR is opened, edited or updated
- `sdkman-set-default.yml` - manual dispatch; sets the given version as the SDKMAN default
- `update-jdk-versions.yml` - weekly (Monday 06:00 UTC) and manual; checks for newer JDK test versions
- `validate-renovate-config.yml` - validates the Renovate configuration when it changes

## V2 Protocol Test Coverage

The workflows ensure comprehensive testing of the v2 protocol implementation:

### Unit Tests (113 total)
- ✅ Binary protocol serialization (26 tests)
- ✅ Edge cases and boundaries (35 tests)
### Unit Tests (109 total)
- ✅ Binary protocol serialization (27 tests)
- ✅ Edge cases and boundaries (27 tests)
- ✅ Performance comparison (2 tests)
- ✅ Protocol negotiation (16 tests)
- ✅ Protocol negotiation (19 tests)
- ✅ Configuration management (18 tests)
- ✅ WireProtocol abstraction (16 tests)

### Test Categories
1. **Command Serialization**
- All 17 BTrace command types
- All 19 BTrace command types
- Round-trip serialization/deserialization
- Compression testing

Expand Down Expand Up @@ -217,8 +228,8 @@ The workflows ensure comprehensive testing of the v2 protocol implementation:
**Publish Job:**
- `GPG_SIGNING_KEY`: GPG key for artifact signing
- `GPG_SIGNING_PWD`: GPG key password
- `BTRACE_SONATYPE_USER`: Sonatype credentials
- `BTRACE_SONATYPE_PWD`: Sonatype credentials
- `SONATYPE_USERNAME` (fallback `BTRACE_SONATYPE_USER`): Sonatype credentials
- `SONATYPE_PASSWORD` (fallback `BTRACE_SONATYPE_PWD`): Sonatype credentials

### Gradle Properties for V2 Testing

Expand All @@ -229,8 +240,8 @@ The workflows ensure comprehensive testing of the v2 protocol implementation:
# Run protocol negotiation tests
./gradlew :btrace-core:test --tests "*Protocol*"

# Run specific JMH benchmarks
./gradlew :btrace-core:jmh -PjmhInclude=".*MessageCommand.*"
# Run specific JMH benchmarks (jmhInclude matches method names; the command type is a JMH parameter)
./gradlew :btrace-core:jmh -PjmhInclude=".*Serialize" --jmhArgs="-p commandType=MessageCommand"

# Generate coverage report
./gradlew :btrace-core:test jacocoTestReport
Expand All @@ -246,10 +257,8 @@ commit message does not trigger it; see the `jmh-benchmarks` job above.
### Benchmark Configuration

**Quick Benchmarks (CI):**
- Warmup: 1 iteration
- Measurement: 2 iterations
- Forks: 1
- Focus: Serialization methods only
- Warmup 1, measurement 2, forks 1 (`-Pjmh.warmupIterations`, `-Pjmh.iterations`, `-Pjmh.fork`)
- Focus: Serialization methods only (`-PjmhInclude=".*Serialize.*"`)

**Full Benchmarks (Local):**
- Warmup: 3 iterations
Expand Down Expand Up @@ -300,7 +309,7 @@ commit message does not trigger it; see the `jmh-benchmarks` job above.

### Expected Metrics
- Serialization: 3-6x faster than V1
- Wire size: 2-5x smaller than V1
- Wire size: about the same as V1, except compressed messages
- Compression: 10-100x size reduction (large messages)

## Maintenance
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,22 @@ jobs:

cd catalog

# Update btrace.java dependency
# btrace (the release alias) follows the release
sed -i.bak -E "s|//DEPS io.btrace:btrace(-client)?:.*|//DEPS io.btrace:btrace:${VERSION}|g" btrace.java

# Update btrace-latest.java dependency
sed -i.bak -E "s|//DEPS io.btrace:btrace(-client)?:.*|//DEPS io.btrace:btrace:${VERSION}|g" btrace-latest.java
# btrace-latest (the snapshot alias) follows develop: a major or minor release moves it to
# the next develop snapshot. A patch release leaves it alone; its next_snapshot is the
# release branch's, older than develop's. Snapshots resolve only from the snapshot
# repository, and any //REPOS line replaces JBang's default Maven Central, so the alias
# must list both.
if [[ "${{ inputs.release_type }}" == "major" || "${{ inputs.release_type }}" == "minor" ]]; then
NEXT="${{ inputs.next_snapshot }}"
sed -i.bak -E "s|//DEPS io.btrace:btrace(-client)?:.*|//DEPS io.btrace:btrace:${NEXT}|g" btrace-latest.java
fi
REPOS='//REPOS mavencentral,central-snapshots=https://central.sonatype.com/repository/maven-snapshots/'
if ! grep -q '^//REPOS ' btrace-latest.java; then
sed -i.bak -E "0,\|^//DEPS |s||${REPOS}\n//DEPS |" btrace-latest.java
fi

# Clean up backup files
rm -f *.bak
Expand Down Expand Up @@ -1450,7 +1461,7 @@ jobs:
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${RELEASE_TAG})" >> $GITHUB_STEP_SUMMARY
echo "- [Maven Central](https://central.sonatype.com/search?q=io.btrace&version=${{ inputs.release_version }})" >> $GITHUB_STEP_SUMMARY
echo "- [SDKMan](https://sdkman.io/sdks#btrace)" >> $GITHUB_STEP_SUMMARY
echo "- JBang: \`jbang btrace@${{ inputs.release_version }}\` (uses Maven Central)" >> $GITHUB_STEP_SUMMARY
echo "- JBang: \`jbang io.btrace:btrace:${{ inputs.release_version }}\` (uses Maven Central)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Maven Coordinates" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/v2-protocol-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,8 @@ jobs:
with:
name: jmh-results
retention-days: 30
path: |
btrace-core/build/reports/jmh/**
btrace-core/build/jmh-results/**
# Where the me.champeau.jmh plugin writes the results by default
path: btrace-core/build/results/jmh/

protocol-compatibility:
name: Protocol Compatibility Matrix
Expand Down
Loading
Loading