module TraceView

Disable docs and Camelcase warns since we're implementing an interface here. See OboeBase for details. rubocop:disable Style/Documentation, Style/MethodName

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Copyright © 2016 SolarWinds, LLC. All rights reserved.

Attributes

logger[RW]

Public Class Methods

sample?(opts = {}) click to toggle source
# File lib/joboe_metal.rb, line 146
def sample?(opts = {})
  begin
    # Return false if no-op mode
    return false unless TraceView.loaded

    return true if ENV.key?('TRACEVIEW_GEM_TEST') && !opts.key?('X-TV-Meta')

    # Validation to make Joboe happy.  Assure that we have the KVs and that they
    # are not empty strings.
    opts[:layer]  = nil      if opts[:layer].is_a?(String)      && opts[:layer].empty?
    opts[:xtrace] = nil      if opts[:xtrace].is_a?(String)     && opts[:xtrace].empty?
    opts['X-TV-Meta'] = nil  if opts['X-TV-Meta'].is_a?(String) && opts['X-TV-Meta'].empty?

    opts[:layer]      ||= nil
    opts[:xtrace]     ||= nil
    opts['X-TV-Meta'] ||= nil

    sr_cfg = Java::ComTracelyticsJoboe::LayerUtil.shouldTraceRequest(opts[:layer], { 'X-Trace' => opts[:xtrace], 'X-TV-Meta' => opts['X-TV-Meta'] })

    # Store the returned SampleRateConfig into TraceView::Config
    if sr_cfg
      begin
        TraceView::Config.sample_rate = sr_cfg.sampleRate
        TraceView::Config.sample_source = sr_cfg.sampleRateSourceValue
        # If we fail here, we do so quietly.  This was we don't spam logs
        # on every request
      end
    else
      TraceView.sample_rate = -1
      TraceView.sample_source = -1
    end

    sr_cfg ? true : false
  rescue => e
    TraceView.logger.debug "[traceview/debug] #{e.message}"
    false
  end
end
set_sample_rate(_rate) click to toggle source
# File lib/joboe_metal.rb, line 189
def set_sample_rate(_rate)
  # N/A
end
set_tracing_mode(_mode) click to toggle source
# File lib/joboe_metal.rb, line 185
def set_tracing_mode(_mode)
  TraceView.logger.warn 'When using JRuby set the tracing mode in /usr/local/tracelytics/javaagent.json instead'
end
support_report() click to toggle source

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize

# File lib/traceview/support.rb, line 22
def self.support_report
  @logger_level = TraceView.logger.level
  TraceView.logger.level = ::Logger::DEBUG

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* BEGIN TraceView Support Report'
  TraceView.logger.warn '*   Please email the output of this report to traceviewsupport@solarwinds.com'
  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn "Ruby: #{RUBY_DESCRIPTION}"
  TraceView.logger.warn "$0: #{$0}"
  TraceView.logger.warn "$1: #{$1}" unless $1.nil?
  TraceView.logger.warn "$2: #{$2}" unless $2.nil?
  TraceView.logger.warn "$3: #{$3}" unless $3.nil?
  TraceView.logger.warn "$4: #{$4}" unless $4.nil?
  TraceView.logger.warn "TraceView.loaded == #{TraceView.loaded}"

  using_jruby = defined?(JRUBY_VERSION)
  TraceView.logger.warn "Using JRuby?: #{yesno(using_jruby)}"
  if using_jruby
    TraceView.logger.warn "Joboe Agent Status: #{Java::ComTracelyticsAgent::Agent.getStatus}"
  end

  on_heroku = TraceView.heroku?
  TraceView.logger.warn "On Heroku?: #{yesno(on_heroku)}"
  if on_heroku
    TraceView.logger.warn "TRACEVIEW_URL: #{ENV['TRACEVIEW_URL']}"
  end

  TraceView.logger.warn "TraceView::Ruby defined?: #{yesno(defined?(TraceView::Ruby))}"
  TraceView.logger.warn "TraceView.reporter: #{TraceView.reporter}"

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* Frameworks'
  TraceView.logger.warn '********************************************************'

  using_rails = defined?(::Rails)
  TraceView.logger.warn "Using Rails?: #{yesno(using_rails)}"
  if using_rails
    TraceView.logger.warn "TraceView::Rails loaded?: #{yesno(defined?(::TraceView::Rails))}"
    TraceView.logger.warn "TraceView::Rack middleware loaded?: #{yesno(::Rails.configuration.middleware.include? TraceView::Rack)}"
  end

  using_sinatra = defined?(::Sinatra)
  TraceView.logger.warn "Using Sinatra?: #{yesno(using_sinatra)}"

  using_padrino = defined?(::Padrino)
  TraceView.logger.warn "Using Padrino?: #{yesno(using_padrino)}"

  using_grape = defined?(::Grape)
  TraceView.logger.warn "Using Grape?: #{yesno(using_grape)}"

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* ActiveRecord Adapter'
  TraceView.logger.warn '********************************************************'
  if defined?(::ActiveRecord)
    if defined?(::ActiveRecord::Base.connection.adapter_name)
      TraceView.logger.warn "ActiveRecord adapter: #{::ActiveRecord::Base.connection.adapter_name}"
    end
  else
    TraceView.logger.warn 'No ActiveRecord'
  end

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* TraceView Libraries'
  TraceView.logger.warn '********************************************************'
  files = []
  ['/usr/lib/liboboe*', '/usr/lib64/liboboe*'].each do |d|
    files = Dir.glob(d)
    break if !files.empty?
  end
  if files.empty?
    TraceView.logger.warn 'Error: No liboboe libs!'
  else
    files.each { |f|
      TraceView.logger.warn f
    }
  end

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* TraceView::Config Values'
  TraceView.logger.warn '********************************************************'
  TraceView::Config.show.each { |k,v|
    TraceView.logger.warn "#{k}: #{v}"
  }

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* OS, Platform + Env'
  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn "host_os: " + RbConfig::CONFIG['host_os']
  TraceView.logger.warn "sitearch: " + RbConfig::CONFIG['sitearch']
  TraceView.logger.warn "arch: " + RbConfig::CONFIG['arch']
  TraceView.logger.warn RUBY_PLATFORM
  TraceView.logger.warn "RACK_ENV: #{ENV['RACK_ENV']}"
  TraceView.logger.warn "RAILS_ENV: #{ENV['RAILS_ENV']}" if using_rails

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* Raw __Init KVs'
  TraceView.logger.warn '********************************************************'
  platform_info = TraceView::Util.build_init_report
  platform_info.each { |k,v|
    TraceView.logger.warn "#{k}: #{v}"
  }

  TraceView.logger.warn '********************************************************'
  TraceView.logger.warn '* END TraceView Support Report'
  TraceView.logger.warn '*   Support Email: traceviewsupport@solarwinds.com'
  TraceView.logger.warn '*   Support Portal: https://tracelytics.freshdesk.com'
  TraceView.logger.warn '*   Github: https://github.com/tracelytics/ruby-traceview'
  TraceView.logger.warn '********************************************************'

  TraceView.logger.level = @logger_level
  nil
end
yesno(x) click to toggle source

yesno

Utility method to translate value/nil to “yes”/“no” strings

# File lib/traceview/support.rb, line 17
def self.yesno(x)
  x ? 'yes' : 'no'
end