Atatus Ruby APM Agent extends your application's logging capabilities with log correlation, allowing you to connect logs, traces, and transactions for easier debugging and deeper observability.
These features help you:
- Automatically include trace and transaction IDs in your application logs.
- Seamlessly connect logs and traces within the Atatus dashboard.
Log Correlation
Log correlation lets you trace individual requests across systems by automatically adding correlation identifiers (trace, transaction, and span IDs) to your logs.
With log correlation enabled, the Atatus Ruby Agent automatically injects these identifiers into your application logs:
| Field | Description |
|---|---|
trace.id |
Uniquely identifies a request across distributed services |
transaction.id |
Marks the primary transaction being traced |
span.id |
Refers to the specific operation within a transaction |
These IDs connect your logs with traces, making it easy to jump from a log entry to its related transaction in the Atatus dashboard.
Rails TaggedLogging
If your Ruby on Rails application uses ActiveSupport::TaggedLogging, you can enable log correlation by adding the following snippet to your environment configuration file (e.g., config/environments/production.rb):
config.log_tags = [:request_id, proc { Atatus.log_ids }]
Example log output:
[transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Started GET "/" for 127.0.0.1
[transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Processing by ApplicationController#index as HTML
[transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Completed 200 OK in 1ms (Views: 0.3ms | Allocations: 187)
Note: Because of the timing of log generation in Rails, the span ID might not always appear in the log output.
Manual Log Formatter
You can also manually customize your logger to include correlation IDs directly in plain Ruby or non-Rails apps.
require 'atatus-apm'
require 'logger'
logger = Logger.new(STDOUT)
logger.progname = 'SampleRubyApp'
logger.formatter = proc do |severity, datetime, progname, msg|
"[#{datetime}][#{progname}][#{severity}][#{Atatus.log_ids}] #{msg}\n"
end
logger.info 'Processing request'
logger.info 'Completed successfully'
This produces logs similar to:
[2025-10-23 10:40:00 +0530][SampleRubyApp][INFO][transaction.id=9b2cdcae trace.id=a87ffd113ebc1fa7] Processing request
[2025-10-23 10:40:00 +0530][SampleRubyApp][INFO][transaction.id=9b2cdcae trace.id=a87ffd113ebc1fa7 span.id=4fabf8cc] Completed successfully
+1-415-800-4104