Automatic Instrumentation
The BrainzLab SDK automatically instruments popular Ruby libraries to provide performance tracing, error context, and logging without any code changes.Supported Libraries
| Library | What’s Tracked | Pulse | Reflex | Recall |
|---|---|---|---|---|
| Rails/Rack | Requests, responses, timing | ✅ | ✅ | ✅ |
| Active Record | SQL queries, duration | ✅ | ✅ | ✅ |
| Net::HTTP | Outbound HTTP calls | ✅ | ✅ | ✅ |
| Faraday | HTTP client requests | ✅ | ✅ | ✅ |
| HTTParty | HTTP client requests | ✅ | ✅ | ✅ |
| Redis | Commands, duration | ✅ | ✅ | ✅ |
| Sidekiq | Jobs, queue wait time | ✅ | ✅ | ✅ |
| Delayed::Job | Jobs, execution time | ✅ | ✅ | ✅ |
| GraphQL | Queries, field resolution | ✅ | ✅ | ✅ |
| Grape | API endpoints | ✅ | ✅ | ✅ |
| MongoDB | Database operations | ✅ | ✅ | ✅ |
| Elasticsearch | Search operations | ✅ | ✅ | ✅ |
| ActionMailer | Email delivery | ✅ | ✅ | ✅ |
Rails/Rack
Automatically instruments all incoming HTTP requests. What’s tracked:- Request method, path, and parameters
- Response status code
- Total request duration
- Controller and action name
- View rendering time
- Database query time breakdown
Active Record
Tracks all SQL queries with timing and query details. What’s tracked:- SQL query (sanitized)
- Query duration
- Table/model name
- Query type (SELECT, INSERT, UPDATE, DELETE)
- Row count (when available)
Net::HTTP
Instruments Ruby’s built-in HTTP client. What’s tracked:- Request method and URL
- Response status code
- Request duration
- Request/response headers (configurable)
traceparent(W3C Trace Context)X-B3-TraceId,X-B3-SpanId(B3 format)
Faraday
Instruments Faraday HTTP client via middleware. What’s tracked:- Request method and URL
- Response status code
- Request duration
- Error details on failure
HTTParty
Instruments HTTParty requests automatically. What’s tracked:- Request method and URL
- Response status code
- Request duration
Redis
Tracks Redis commands with timing. What’s tracked:- Command name (GET, SET, HGET, etc.)
- Key (first argument)
- Duration
- Database number
- Redis gem v4.x (via monkey-patching)
- Redis gem v5.x+ (via middleware)
Sidekiq
Full instrumentation for Sidekiq background jobs. What’s tracked:- Job class and arguments
- Queue name
- Queue wait time (time in queue before processing)
- Execution duration
- Retry count
- Error details on failure
ServerMiddleware- Traces job executionClientMiddleware- Injects trace context when enqueueing
Delayed::Job
Instruments Delayed::Job background processing. What’s tracked:- Job class/method name
- Queue name
- Queue wait time
- Execution duration
- Retry attempts
- Failure details
- Automatic via lifecycle hooks
- Plugin:
Delayed::Worker.plugins << BrainzLab::Instrumentation::DelayedJobInstrumentation::Plugin
GraphQL
Instruments GraphQL-Ruby queries and mutations. What’s tracked:- Query/mutation name
- Operation type
- Execution duration
- Field resolution (fields >10ms)
- Variables (sanitized)
- Errors
Grape
Instruments Grape API endpoints. What’s tracked:- HTTP method and path
- Route pattern
- Response status
- Endpoint duration
- Filter execution time
MongoDB
Instruments MongoDB operations via the Ruby driver. What’s tracked:- Command name (find, insert, update, delete, aggregate)
- Collection name
- Duration
- Document count
mongogem (MongoDB Ruby Driver)mongoidODM
Elasticsearch
Instruments Elasticsearch and OpenSearch queries. What’s tracked:- Operation type (search, index, delete, bulk)
- Index name
- Duration
- Query details (sanitized)
elasticsearchgemopensearch-rubygem- Elastic 8.x client
ActionMailer
Tracks email delivery with ActionMailer. What’s tracked:- Mailer class and action
- Recipients (masked for privacy)
- Subject (truncated)
- Delivery duration
- Message ID
[email protected]→jo***@example.com