module AppPerfRpm
Constants
- TRACE_CONTEXT_KEY
Attributes
config[W]
logger[RW]
Public Class Methods
collector()
click to toggle source
# File lib/app_perf_rpm.rb, line 62 def collector @collector ||= AppPerfRpm::Tracing::Collector.new(endpoint) end
config()
click to toggle source
# File lib/app_perf_rpm.rb, line 38 def config @config ||= Configuration.new end
configure() { |config| ... }
click to toggle source
# File lib/app_perf_rpm.rb, line 42 def configure yield(config) end
disable_agent?()
click to toggle source
# File lib/app_perf_rpm.rb, line 145 def disable_agent? if config.agent_disabled true elsif Introspector.agentable? false else true end end
endpoint()
click to toggle source
# File lib/app_perf_rpm.rb, line 58 def endpoint @endpoint ||= AppPerfRpm::Tracing::Endpoint.local_endpoint(config.application_name) end
floor_time(t, sec = 1)
click to toggle source
# File lib/app_perf_rpm.rb, line 141 def floor_time(t, sec = 1) Time.at((t.to_f / sec).floor * sec) end
host()
click to toggle source
# File lib/app_perf_rpm.rb, line 121 def host @host ||= Socket.gethostname end
load()
click to toggle source
# File lib/app_perf_rpm.rb, line 46 def load #Oj.mimic_JSON unless disable_agent? AppPerfRpm::Instrumentation.load AppPerfRpm.tracing_on end end
mutex()
click to toggle source
# File lib/app_perf_rpm.rb, line 54 def mutex @mutex ||= Mutex.new end
now()
click to toggle source
# File lib/app_perf_rpm.rb, line 155 def now if defined?(Process::CLOCK_REALTIME) Process.clock_gettime(Process::CLOCK_REALTIME) else Time.now end end
round_time(t, sec = 1)
click to toggle source
# File lib/app_perf_rpm.rb, line 125 def round_time(t, sec = 1) t = Time.parse(t.to_s) down = t - (t.to_i % sec) up = down + sec difference_down = t - down difference_up = up - t if (difference_down < difference_up) return down else return up end end
sender()
click to toggle source
# File lib/app_perf_rpm.rb, line 70 def sender @sender ||= AppPerfRpm::Reporters::JsonClient.new( url: url, collector: collector, flush_interval: config.flush_interval ) end
tracer()
click to toggle source
# File lib/app_perf_rpm.rb, line 78 def tracer @tracer ||= AppPerfRpm::Tracing::ManagedTracer.new( AppPerfRpm::Tracing::Tracer.build( :service_name => config.application_name, :sender => sender, :collector => collector ), AppPerfRpm::Tracing::ThreadSpanStack.new ) end
tracing?()
click to toggle source
# File lib/app_perf_rpm.rb, line 107 def tracing? !!@tracing end
tracing_off()
click to toggle source
# File lib/app_perf_rpm.rb, line 100 def tracing_off mutex.synchronize do AppPerfRpm.logger.debug "Disabling tracing." @tracing = false end end
tracing_on()
click to toggle source
# File lib/app_perf_rpm.rb, line 89 def tracing_on if @without_tracing_enabled AppPerfRpm.logger.debug "Not turning tracing on due to without tracing mode." return end mutex.synchronize do AppPerfRpm.logger.debug "Enabling tracing." @tracing = true end end
url()
click to toggle source
# File lib/app_perf_rpm.rb, line 66 def url @url ||= "#{config.host}/api/listener/3/#{config.license_key}" end
without_tracing() { || ... }
click to toggle source
# File lib/app_perf_rpm.rb, line 111 def without_tracing @previously_tracing = AppPerfRpm.tracing? @without_tracing_enabled = true AppPerfRpm.tracing_off yield if block_given? @without_tracing_enabled = false ensure AppPerfRpm.tracing_on if @previously_tracing end