File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -96,9 +96,11 @@ def correlation
9696 # # dd.env=prod dd.service=auth dd.version=13.8 dd.trace_id=5458478252992251 dd.span_id=7117552347370098 My message
9797 # ```
9898 #
99- # @return [String] correlation information
99+ # @return [String] correlation information; or an empty String if Tracing is disabled (`!enabled?`)
100100 # @public_api
101101 def log_correlation
102+ return '' unless enabled?
103+
102104 correlation . to_log_format
103105 end
104106
Original file line number Diff line number Diff line change 106106 expect ( log_correlation ) . to eq ( returned )
107107 end
108108 # rubocop:enable RSpec/MessageChain
109+
110+ context 'with tracing disabled' do
111+ before do
112+ allow ( Datadog . send ( :components ) . tracer ) . to receive ( :enabled ) . and_return ( false )
113+ end
114+
115+ it 'returns an empty string' do
116+ expect ( log_correlation ) . to eq ( '' )
117+ end
118+ end
109119 end
110120
111121 describe '.shutdown!' do
You can’t perform that action at this time.
0 commit comments