⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@jbachorik
Copy link
Collaborator

@jbachorik jbachorik commented Jan 13, 2026

Summary

This PR introduces provided-style extensions and fat agent deployment for BTrace, enabling application class tracing without classpath pollution and single-JAR deployment for distributed environments.

Features

Provided-Style Extensions

  • Application class tracing without classpath injection - Access classes loaded by application classloader through reflection
  • Runtime class discovery - ClassLoadingUtil loads classes from application context at trace time
  • Safe method handles - MethodHandleCache provides efficient, cached reflective access
  • Manifest-driven library management - New declarative approach replaces error-prone libs= parameter

Embedded Extensions & Fat Agent

  • Single-JAR deployment - Bundle agent + extensions into one JAR for Spark/Hadoop/Kubernetes
  • ClassDataLoader - Runtime loading of impl classes from .classdata resources
  • EmbeddedExtensionRepository - Discovers extensions from JAR manifest
  • Gradle Plugin (org.openjdk.btrace.fat-agent) - Auto-discovers extensions, supports project/maven/file sources
  • Maven Plugin (btrace-maven-plugin) - Equivalent functionality for Maven users

Bug Fixes

  • Bootstrap classloader NPE in Main and EmbeddedExtensionRepository
  • Probe listing after disconnect and test isolation
  • Thread retransform after startup scripts for early hooks
  • Java 8 compatibility (List.of → Collections.emptyList)

Documentation

Document Description
Fat Agent Plugin Architecture Single-JAR deployment design
Provided-Style Extensions API on bootstrap, impl via TCCL
Migration Guide Migrating from deprecated libs/profiles
Extension Development Guide Building extensions
Gradle Plugin README Both extension and fat-agent plugins

Example Extensions

Usage

Fat Agent (Gradle)

plugins { id 'org.openjdk.btrace.fat-agent' }
btraceFatAgent {
    embedExtensions {
        project(':btrace-metrics')
        maven('io.btrace:btrace-statsd:2.3.0')
    }
}

Fat Agent (Maven)

<plugin>
    <groupId>org.openjdk.btrace</groupId>
    <artifactId>btrace-maven-plugin</artifactId>
    <configuration>
        <extensions>
            <extension>io.btrace:btrace-metrics:${btrace.version}</extension>
        </extensions>
    </configuration>
</plugin>

Breaking Changes

  • libs= and profiles= deprecated (removal planned N+2)

🤖 Generated with Claude Code

@jbachorik jbachorik added the AI AI-generated code label Jan 13, 2026
Copy link

@reviewabot reviewabot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the pull request diff is too large to be displayed directly on GitHub. Here are some general recommendations for handling large pull requests:

  1. Break Down the PR: Try to break down the pull request into smaller, more manageable chunks. This makes it easier to review and ensures that each part can be thoroughly checked.

  2. Review Locally: Clone the repository and check out the branch locally. This allows you to review the changes using your preferred tools and environment.

  3. Focus on Key Areas: Identify and focus on the key areas of the code that are most critical or have the highest impact. This can help prioritize the review process.

  4. Automated Tools: Use automated code review tools and linters to catch common issues and enforce coding standards.

  5. Collaborate with the Team: If possible, involve multiple reviewers to share the workload and get different perspectives on the changes.

If you can provide a smaller subset of the changes or specific files that need review, I'd be happy to help with a more detailed review.

@jbachorik jbachorik changed the title fix(agent,client,tests): probe listing after disconnect and test isolation feat: manifest-libs, provided-style extensions, permission removal, and fixes Jan 13, 2026
@jbachorik jbachorik changed the title feat: manifest-libs, provided-style extensions, permission removal, and fixes feat: provided-style extensions and manifest-libs Jan 13, 2026
jbachorik and others added 3 commits January 13, 2026 17:29
…ibs deprecation; provided-style helpers; examples; tests\n\n- agent: manifest-driven libs (flagged), centralized classpath append with dedup + diagnostics; deprecate libs (debug log); add single-jar system CL escape hatch; test knob scoped to manifest-libs\n- client: pass-through of btrace.* props to agent using $ system props\n- extension: add ClassLoadingUtil and MethodHandleCache for provided-style extensions\n- examples: add btrace-extensions/examples/{btrace-spark,btrace-hadoop} with README\n- docs: research + provided-style guide + migration + examples index; README deprecation note\n- tests: add ManifestLibsTests; gradle knob for btrace.test.skipLibs\n\nBREAKING CHANGE: libs/profiles deprecated with planned removal after N+2; prefer extensions
- Proactively retransform java.lang.Thread after startup scripts load
- Move initExtensions() after transformer is installed
- Add delay in RuntimeTest to allow traced app output after ready marker

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ation

- Add disconnecting flag to RemoteClient for immediate probe visibility
- Skip loadAgent when agent already running (check btrace.port)
- Add try-finally cleanup in tests to prevent port conflicts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces provided-style extensions and manifest-driven library loading to enable tracing application-specific classes without polluting the application classpath. The core innovation is using reflection and object hand-off patterns to access application classes at runtime, keeping BTrace isolated.

Changes:

  • New extension utilities (ClassLoadingUtil, MethodHandleCache) for runtime class resolution and reflective method access
  • Manifest-driven library path resolution (AgentManifestLibs) with security restrictions to BTRACE_HOME
  • Refactored agent classpath processing with deduplication and better error handling
  • Example extensions for Spark and Hadoop demonstrating the provided-style pattern
  • Comprehensive architecture documentation and migration guides
  • Deprecation of libs/profiles mechanism with escape hatch for edge cases

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
settings.gradle Added example extension modules (btrace-spark, btrace-hadoop)
integration-tests/src/test/java/tests/RuntimeTest.java Fixed debug flag insertion and added timing delays for test stability
integration-tests/src/test/java/tests/ManifestLibsTests.java New test suite for manifest-libs feature
integration-tests/src/test/java/tests/BTraceFunctionalTests.java Improved unattended test with better synchronization and cleanup
integration-tests/build.gradle Added test property for skipping preconfigured libs
docs/examples/README.md Guide for building and configuring provided-style extension examples
docs/architecture/provided-style-extensions.md Comprehensive guide on provided-style extension pattern
docs/architecture/migrating-from-libs-profiles.md Migration guide from deprecated libs/profiles to extensions
docs/architecture/agent-manifest-libs.md Design document for manifest-driven library loading
compile.log Build artifact that should not be committed
btrace-extensions/examples/btrace-spark/* Example Spark extension with API and provided-style implementation
btrace-extensions/examples/btrace-hadoop/* Example Hadoop extension with API and provided-style implementation
btrace-extension/src/main/java/org/openjdk/btrace/extension/util/MethodHandleCache.java Cache for reflective method handles to reduce lookup overhead
btrace-extension/src/main/java/org/openjdk/btrace/extension/util/ClassLoadingUtil.java Helper utilities for TCCL-based class loading and service discovery
btrace-client/src/main/java/org/openjdk/btrace/client/Main.java Removed exit hooks for list-only operations to prevent unintended probe removal
btrace-client/src/main/java/org/openjdk/btrace/client/Client.java Added agent-already-running detection and system property pass-through
btrace-agent/src/main/java/org/openjdk/btrace/agent/RemoteClient.java Improved disconnect handling with disconnecting flag
btrace-agent/src/main/java/org/openjdk/btrace/agent/Main.java Refactored classpath processing with manifest support, deduplication, and escape hatch for single-jar injection
btrace-agent/src/main/java/org/openjdk/btrace/agent/AgentManifestLibs.java New utility for manifest-driven library resolution with security checks
README.md Added deprecation notice for libs/profiles with migration guidance

Manifest mf = readManifest(anchor);
if (mf == null) {
if (log.isDebugEnabled()) log.debug("No manifest found for agent; skipping manifest libs");
return new ResolvedLibs(List.of(), List.of());
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code uses List.of() which was introduced in Java 9, but the project targets Java 8. This will cause a compilation error. Use Collections.emptyList() or Arrays.asList() instead for Java 8 compatibility.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Jan 13, 2026

@jbachorik I've opened a new pull request, #792, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 13, 2026

@jbachorik I've opened a new pull request, #793, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 13, 2026

@jbachorik I've opened a new pull request, #794, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits January 14, 2026 09:55
- Add ExtensionConfigurator interface for environment-aware probe selection
- Add ProbeConfiguration and RuntimeEnvironment classes
- Add ClassDataLoader for loading .classdata resources (dd-trace pattern)
- Add EmbeddedExtensionRepository for discovering embedded extensions
- Extend ExtensionDescriptorDTO with embedded, resourceBasePath, configuratorClass, bundledProbes fields
- Register EmbeddedExtensionRepository in ExtensionLoader (lowest priority)
- Handle embedded extensions in ExtensionLoaderImpl via ClassDataLoader

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- gradle: BTraceFatAgentPlugin with auto-discovery, project/maven/file sources
- maven: btrace-maven-plugin with fat-agent goal (Gradle-built module)
- fix: bootstrap classloader NPE in Main and EmbeddedExtensionRepository
- docs: fat-agent-plugin architecture, getting started, migration guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI AI-generated code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants