Skip to content

Conversation

@delner
Copy link
Collaborator

@delner delner commented Dec 19, 2025

Overview

I took some time to explore what's possible to automatically instrument with Ruby.

Here are four new ways to instrument applications with LLM libraries, from most automatic to most controlled:


Zero Code - CLI wrapper instruments any Ruby app without code changes

Best for: Instrumenting any Ruby application without modifying its code. Requires the braintrust Ruby gem to already be installed in the bundle via Gemfile or on the system.

braintrust exec -- ruby app.rb
braintrust exec --only openai -- rails server

Zero Config - Just require (works with Bundler/Rails)

Best for: Instrumenting specific Ruby applications with smart defaults and maximum compatibility.

# In Gemfile
gem "braintrust", require: "braintrust/contrib/auto_instrument"

Single Line - Auto-instruments on init (new default behavior):

Best for: Controlling when and what instrumentation is activated.

require "braintrust"
Braintrust.init  # All available integrations instrumented automatically

# Or with filtering:
Braintrust.init(auto_instrument: { only: [:openai] })
Braintrust.init(auto_instrument: false)  # Opt-out

Explicit - Direct control over when instrumentation is applied:

Best for: Fine-control over when and which parts of an application are instrumented.

Braintrust::Contrib.auto_instrument!                    # All available
Braintrust::Contrib.auto_instrument!(only: [:openai])   # Same filtering API as `Braintrust.init`

Braintrust::Contrib.instrument!(:openai, target: client) # Per-instance manual instrumentation

All options support environment variable overrides: BRAINTRUST_AUTO_INSTRUMENT, BRAINTRUST_INSTRUMENT_ONLY, BRAINTRUST_INSTRUMENT_EXCEPT.

@delner delner requested review from clutchski and realark December 19, 2025 02:31
@delner delner self-assigned this Dec 19, 2025
@delner delner added the enhancement New feature or request label Dec 19, 2025
@delner
Copy link
Collaborator Author

delner commented Dec 19, 2025

Closing this while I reformulate PRs.

@delner delner closed this Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants