Sha256: 92997fb32ca38f20da19ea7bcbf91f983d3eb5884e75bf85ef7674e086f3f9cb

Contents?: true

Size: 1.38 KB

Versions: 44

Compression:

Stored size: 1.38 KB

Contents

require 'rubygems'
require 'bundler'

Bundler.require

# Make sure oboe is at the bottom of your Gemfile.
# This is likely redundant but just in case.
require 'oboe'

# Tracing mode can be 'never', 'through' (to follow upstream) or 'always'
Oboe::Config[:tracing_mode] = 'always'

#
# Update April 9, 2015 - this is done automagically now
# and doesn't have to be called manually
#
# Load library instrumentation to auto-capture stuff we know about...
# e.g. ActiveRecord, Cassandra, Dalli, Redis, memcache, mongo
# Oboe::Ruby.load

# Some KVs to report to the dashboard
report_kvs = {}
report_kvs[:command_line_params] = ARGV.to_s
report_kvs[:user_id] = `whoami`

Oboe::API.start_trace('my_background_job', nil, report_kvs ) do
  #
  # Initialization code
  #

  tasks = get_all_tasks

  tasks.each do |t|
    # Optional: Here we embed another 'trace' to separate actual
    # work for each task.  In the TV dashboard, this will show
    # up as a large 'my_background_job' parent layer with many
    # child 'task" layers.
    Oboe::API.trace('task', { :task_id => t.id }) do
      t.perform
    end
  end
  #
  # cleanup code
  #
end

# Note that we use 'start_trace' in the outer block and 'trace' for
# any sub-blocks of code we wish to instrument.  The arguments for
# both methods vary slightly.  Details in RubyDoc:
# https://www.omniref.com/ruby/gems/oboe/2.7.10.1/symbols/Oboe::API::Tracing#tab=Methods


Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
traceview-3.8.1-java examples/tracing_background_jobs.rb
traceview-3.8.1 examples/tracing_background_jobs.rb
traceview-3.8.0-java examples/tracing_background_jobs.rb
traceview-3.8.0 examples/tracing_background_jobs.rb
traceview-3.7.1-java examples/tracing_background_jobs.rb
traceview-3.7.1 examples/tracing_background_jobs.rb
traceview-3.7.0-java examples/tracing_background_jobs.rb
traceview-3.7.0 examples/tracing_background_jobs.rb
traceview-3.6.0-java examples/tracing_background_jobs.rb
traceview-3.6.0 examples/tracing_background_jobs.rb
traceview-3.5.1-java examples/tracing_background_jobs.rb
traceview-3.5.1 examples/tracing_background_jobs.rb
traceview-3.5.0-java examples/tracing_background_jobs.rb
traceview-3.5.0 examples/tracing_background_jobs.rb
traceview-3.4.2-java examples/tracing_background_jobs.rb
traceview-3.4.2 examples/tracing_background_jobs.rb
traceview-3.4.1-java examples/tracing_background_jobs.rb
traceview-3.4.1 examples/tracing_background_jobs.rb
traceview-3.4.0-java examples/tracing_background_jobs.rb
traceview-3.4.0 examples/tracing_background_jobs.rb