@@ -40,7 +40,7 @@ module Logging
40
40
#
41
41
# Returns nothing.
42
42
def log ( layer , label , opts = { } , event = nil )
43
- return if ! AppOpticsAPM . tracing?
43
+ return AppOpticsAPM :: Context . toString unless AppOpticsAPM . tracing?
44
44
45
45
event ||= AppOpticsAPM ::Context . createEvent
46
46
log_event ( layer , label , event , opts )
@@ -66,11 +66,11 @@ def log(layer, label, opts = {}, event=nil)
66
66
#
67
67
# Returns nothing.
68
68
def log_exception ( layer , exn , opts = { } )
69
- return if !AppOpticsAPM . tracing? || exn . instance_variable_get ( :@oboe_logged )
69
+ return AppOpticsAPM :: Context . toString if !AppOpticsAPM . tracing? || exn . instance_variable_get ( :@oboe_logged )
70
70
71
71
unless exn
72
72
AppOpticsAPM . logger . debug '[appoptics_apm/debug] log_exception called with nil exception'
73
- return
73
+ return AppOpticsAPM :: Context . toString
74
74
end
75
75
76
76
opts . merge! ( :ErrorClass => exn . class . name ,
@@ -180,12 +180,11 @@ def log_start(layer, xtrace = nil, opts = {})
180
180
#
181
181
# Returns an xtrace metadata string if we are tracing
182
182
def log_end ( layer , opts = { } )
183
- return unless AppOpticsAPM . tracing?
183
+ return AppOpticsAPM :: Context . toString unless AppOpticsAPM . tracing?
184
184
185
- log_event ( layer , :exit , AppOpticsAPM ::Context . createEvent , opts ) if AppOpticsAPM . tracing?
186
- AppOpticsAPM ::Context . toString
185
+ log_event ( layer , :exit , AppOpticsAPM ::Context . createEvent , opts )
187
186
ensure
188
- # FIXME has_incoming_context commented out, it has importance for JRuby only and breaks ruby tests
187
+ # FIXME has_incoming_context commented out, it has importance for JRuby only but breaks Ruby tests
189
188
AppOpticsAPM ::Context . clear # unless AppOpticsAPM.has_incoming_context?
190
189
end
191
190
@@ -206,7 +205,7 @@ def log_end(layer, opts = {})
206
205
#
207
206
# Returns an xtrace metadata string if we are tracing
208
207
def log_entry ( layer , opts = { } , op = nil )
209
- return unless AppOpticsAPM . tracing?
208
+ return AppOpticsAPM :: Context . toString unless AppOpticsAPM . tracing?
210
209
211
210
AppOpticsAPM . layer_op = op . to_sym if op
212
211
log_event ( layer , :entry , AppOpticsAPM ::Context . createEvent , opts )
@@ -228,7 +227,7 @@ def log_entry(layer, opts = {}, op = nil)
228
227
#
229
228
# Returns an xtrace metadata string if we are tracing
230
229
def log_info ( layer , opts = { } )
231
- return unless AppOpticsAPM . tracing?
230
+ return AppOpticsAPM :: Context . toString unless AppOpticsAPM . tracing?
232
231
233
232
log_event ( layer , :info , AppOpticsAPM ::Context . createEvent , opts )
234
233
end
@@ -251,7 +250,7 @@ def log_info(layer, opts = {})
251
250
#
252
251
# Returns an xtrace metadata string if we are tracing
253
252
def log_exit ( layer , opts = { } , op = nil )
254
- return unless AppOpticsAPM . tracing?
253
+ return AppOpticsAPM :: Context . toString unless AppOpticsAPM . tracing?
255
254
256
255
AppOpticsAPM . layer_op = nil if op
257
256
log_event ( layer , :exit , AppOpticsAPM ::Context . createEvent , opts )
@@ -270,7 +269,7 @@ def log_exit(layer, opts = {}, op = nil)
270
269
# * +traces+ - An array with X-Trace strings returned from the requests
271
270
#
272
271
def log_multi_exit ( layer , traces )
273
- return unless AppOpticsAPM . tracing?
272
+ return AppOpticsAPM :: Context . toString unless AppOpticsAPM . tracing?
274
273
task_id = AppOpticsAPM ::XTrace . task_id ( AppOpticsAPM ::Context . toString )
275
274
event = AppOpticsAPM ::Context . createEvent
276
275
traces . each do |trace |
@@ -289,7 +288,7 @@ def log_multi_exit(layer, traces)
289
288
# * +opts+ - A hash containing key/value pairs that will be reported along with this event
290
289
def log_init ( layer = :rack , opts = { } )
291
290
context = AppOpticsAPM ::Metadata . makeRandom
292
- return unless context . isValid
291
+ return AppOpticsAPM :: Context . toString unless context . isValid
293
292
294
293
event = context . createEvent
295
294
event . addInfo ( APPOPTICS_STR_LAYER , layer . to_s )
@@ -299,6 +298,7 @@ def log_init(layer = :rack, opts = {})
299
298
end
300
299
301
300
AppOpticsAPM ::Reporter . sendStatus ( event , context )
301
+ AppOpticsAPM ::Context . toString
302
302
end
303
303
304
304
private
@@ -353,6 +353,7 @@ def log_event(layer, label, event, opts = {})
353
353
end if !opts . nil? && opts . any?
354
354
355
355
AppOpticsAPM ::Reporter . sendReport ( event )
356
+ AppOpticsAPM ::Context . toString
356
357
end
357
358
358
359
end
0 commit comments