Code Beacon is a Visual Studio Code extension that helps you reason about recently executed Ruby code and navigate between relevant files and methods. A file explorer-like view is presented that filters out all of the noise and only shows you the files for one of your code flows. Drilling down into each file provides a list of methods and blocks that were traced for a given recording.
This extension is only part of the entire offering and requires the codebeacon-tracer gem to be installed and configured to record. See installation below.
⚠️ Pre-release Warning: This is a pre-release version of Code Beacon. While core functionality exists and may provide utility, you may encounter significant bugs or issues and frequent breaking changes. Testing is currently limited, and the UI and future direction may change. We appreciate your feedback and bug reports as we work towards a stable release.
Installation
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Search for "Code Beacon"
Click Install
Requirements
Visual Studio Code 1.85.0 or higher
Ruby 2.7 or higher
A Ruby project with the Code Beacon gem installed
Getting Started
Install the Code Beacon gem in your Ruby project:
gem install codebeacon_tracer
Or add to your Gemfile:
gem 'codebeacon_tracer'
Add the Code Beacon tracer to your Ruby application:
require 'codebeacon_tracer'
# Trace a block of code
CodeBeacon::Tracer.trace("My Trace", "Description of what I'm tracing") do |tracer|
# Your code to analyze goes here
some_method_to_analyze
end
# Or start and stop tracing manually
CodeBeacon::Tracer.start
# Your code to analyze
some_method_to_analyze
CodeBeacon::Tracer.stop
Rails Applications: In Rails applications, HTTP requests are automatically traced without any additional code. Simply install the gem and run your Rails server as usual.
Run your application to generate execution data
Open the Code Beacon panel in VS Code (look for the beacon icon in the activity bar)
Browse through the recorded method calls and execution paths
Extension Settings
This extension contributes the following settings:
code-beacon.dataDir: Set the root directory name for the data files in the workspace root (default: .code-beacon)
code-beacon.rootDir: Used only in the case of a multi-root workspace. Enable a single root directory by setting its path here.
Known Issues
Currently only supports Ruby applications
Large applications with many method calls may experience performance issues
This is especially true on initial load or reload of a rails application.
The first request after a rails server is started is not traced.