Module: Oboe::Inst::Resque

Defined in:
lib/oboe/inst/resque.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
# File 'lib/oboe/inst/resque.rb', line 10

def self.included(base)
  base.send :extend, ::Resque
end

Instance Method Details

#dequeue_with_oboe(klass, *args) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/oboe/inst/resque.rb', line 66

def dequeue_with_oboe(klass, *args)
  if Oboe.tracing?
    report_kvs = extract_trace_details(:dequeue, klass, args)

    Oboe::API.trace('resque-client', report_kvs) do
      dequeue_without_oboe(klass, *args)
    end
  else
    dequeue_without_oboe(klass, *args)
  end
end

#enqueue_to_with_oboe(queue, klass, *args) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/oboe/inst/resque.rb', line 52

def enqueue_to_with_oboe(queue, klass, *args)
  if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:enqueue)
    report_kvs = extract_trace_details(:enqueue_to, klass, args)
    report_kvs[:Queue] = queue.to_s if queue

    Oboe::API.trace('resque-client', report_kvs) do
      args.push({:parent_trace_id => Oboe::Context.toString}) if Oboe::Config[:resque][:link_workers]
      enqueue_to_without_oboe(queue, klass, *args)
    end
  else
    enqueue_to_without_oboe(queue, klass, *args)
  end
end

#enqueue_with_oboe(klass, *args) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/oboe/inst/resque.rb', line 39

def enqueue_with_oboe(klass, *args)
  if Oboe.tracing?
    report_kvs = extract_trace_details(:enqueue, klass, args)

    Oboe::API.trace('resque-client', report_kvs, :enqueue) do
      args.push({:parent_trace_id => Oboe::Context.toString}) if Oboe::Config[:resque][:link_workers]
      enqueue_without_oboe(klass, *args)
    end
  else
    enqueue_without_oboe(klass, *args)
  end
end

#extract_trace_details(op, klass, args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/oboe/inst/resque.rb', line 14

def extract_trace_details(op, klass, args)
  report_kvs = {}

  begin
    report_kvs[:Op] = op.to_s
    report_kvs[:Class] = klass.to_s if klass

    if Oboe::Config[:resque][:log_args]
      kv_args = args.to_json
      
      # Limit the argument json string to 1024 bytes
      if kv_args.length > 1024
        report_kvs[:Args] = kv_args[0..1023] + '...[snipped]'
      else
        report_kvs[:Args] = kv_args
      end
    end
    
    report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:resque][:collect_backtraces]
  rescue
  end

  report_kvs
end