-
Notifications
You must be signed in to change notification settings - Fork 24
Description
This proposal suggests adding a web-based UI component to reduce friction when working with compile-time instrumentation. The UI would provide interactive code exploration, automatic hook generation, and debugging capabilities for instrumented applications.
Motivation
Compile-time instrumentation using AOP techniques introduces an abstraction layer that can be challenging to work with:
- Hidden complexity: The final instrumented code differs from the source code, making it hard to understand what actually runs
- Manual hook creation: Writing hook definitions requires understanding function signatures, package paths, and the instrumentation API
- Debugging difficulty: When issues occur, developers need to inspect the modified code in Go's WORK directory
- Discovery problem: Finding which functions to instrument in large codebases is tedious
Currently, users must:
- Manually browse source files to find functions
- Hand-write YAML/DSL rules with correct package paths and signatures
- Run builds and hope the instrumentation works
- Debug issues by manually inspecting temporary build artifacts
Proposed Solution
A web-based UI that provides multiple views into the codebase and build process:
- Code Exploration Views
| View | Description |
|---|---|
| Functions | List all functions in the project with signatures |
| Static Call Graph | Visualize function call relationships |
| Packages | Browse packages involved in compilation |
| Files | Navigate source files with syntax highlighting |
| WORK Directory | Inspect instrumented files in their final form |
- Hook Generation
- Select functions via checkboxes in the Functions view
- Click "Generate Hooks" to auto-create hook boilerplate
- Generated code includes:
- Proper package paths
- Correct function signatures
- Before/After hook templates with timing measurement
- Build & Run Integration
- Compile: Select hook files and build with instrumentation
- Run: Execute instrumented binaries directly from the UI
- View Output: See console output with tracing information
- Debugging Support
- Step through instrumented code with breakpoints
- Inspect the final modified source files
- Verify hook injection points
- Compare original vs instrumented code
Benefits
| Problem | UI Solution |
|---|---|
| Finding functions to instrument | Functions view with search/filter |
| Writing correct hook definitions | Auto-generation with proper signatures |
| Understanding call flow | Static call graph visualization |
| Debugging instrumented code | WORK directory inspection + debugger |
| Verifying instrumentation | Side-by-side original vs modified view |
Integration with Existing Tooling
The UI would be a standalone component that:
- Works with the existing -toolexec based instrumentation
- Reads the same YAML/Go DSL rule files
- Can be used independently or alongside IDE plugins
- Potentially shareable with other instrumentation projects
Reference Implementation
A working implementation exists in https://github.com/pdelewski/go-build-interceptor with:
- Full source at ui/ directory
- Cross-platform support (Linux, macOS, Windows)
- Monaco editor integration with Go LSP
- Debugging via delve integration
Screenshots:
https://github.com/pdelewski/go-build-interceptor/blob/main/docs/images/ui-screenshot.png
Workflow Demo:
https://github.com/pdelewski/go-build-interceptor/blob/main/docs/images/go-build-interceptor.gif
Next Steps
- Evaluate UI codebase for integration
- Adapt UI to work with existing otel-go-instrumentation build system
Open Questions
- Should this be part of the main repo or a separate companion project?