Module: AppPerfRpm
- Defined in:
- lib/app_perf_rpm.rb,
lib/app_perf_rpm/utils.rb,
lib/app_perf_rpm/logger.rb,
lib/app_perf_rpm/tracer.rb,
lib/app_perf_rpm/railtie.rb,
lib/app_perf_rpm/backtrace.rb,
lib/app_perf_rpm/introspector.rb,
lib/app_perf_rpm/tracing/span.rb,
lib/app_perf_rpm/configuration.rb,
lib/app_perf_rpm/tracing/buffer.rb,
lib/app_perf_rpm/tracing/tracer.rb,
lib/app_perf_rpm/instrumentation.rb,
lib/app_perf_rpm/tracing/carrier.rb,
lib/app_perf_rpm/instruments/rack.rb,
lib/app_perf_rpm/instruments/rack.rb,
lib/app_perf_rpm/tracing/endpoint.rb,
lib/app_perf_rpm/tracing/trace_id.rb,
lib/app_perf_rpm/instruments/grape.rb,
lib/app_perf_rpm/tracing/collector.rb,
lib/app_perf_rpm/instruments/sequel.rb,
lib/app_perf_rpm/instruments/faraday.rb,
lib/app_perf_rpm/instruments/sidekiq.rb,
lib/app_perf_rpm/instruments/sinatra.rb,
lib/app_perf_rpm/instruments/typhoeus.rb,
lib/app_perf_rpm/tracing/managed_span.rb,
lib/app_perf_rpm/tracing/span_context.rb,
lib/app_perf_rpm/reporters/json_client.rb,
lib/app_perf_rpm/reporters/null_client.rb,
lib/app_perf_rpm/tracing/managed_tracer.rb,
lib/app_perf_rpm/instruments/active_record.rb,
lib/app_perf_rpm/tracing/thread_span_stack.rb,
lib/app_perf_rpm/instruments/emque_consuming.rb,
lib/app_perf_rpm/instruments/action_controller.rb,
lib/app_perf_rpm/instruments/activerecord_import.rb,
lib/app_perf_rpm/instruments/active_record/adapters/mysql2.rb,
lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb,
lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb
Defined Under Namespace
Modules: Instruments, Reporters, Tracing, Utils
Classes: Backtrace, Configuration, Instrumentation, Introspector, Logger, Railtie, SidekiqClient, SidekiqServer, Tracer
Constant Summary
collapse
- TRACE_CONTEXT_KEY =
'AppPerf-Trace-Context'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.config ⇒ Object
37
38
39
|
# File 'lib/app_perf_rpm.rb', line 37
def config
@config ||= Configuration.new
end
|
.logger ⇒ Object
Returns the value of attribute logger.
7
8
9
|
# File 'lib/app_perf_rpm/logger.rb', line 7
def logger
@logger
end
|
Class Method Details
41
42
43
|
# File 'lib/app_perf_rpm.rb', line 41
def configure
yield(config)
end
|
.disable_agent? ⇒ Boolean
144
145
146
147
148
149
150
151
152
|
# File 'lib/app_perf_rpm.rb', line 144
def disable_agent?
if config.agent_disabled
true
elsif Introspector.agentable?
false
else
true
end
end
|
.floor_time(t, sec = 1) ⇒ Object
140
141
142
|
# File 'lib/app_perf_rpm.rb', line 140
def floor_time(t, sec = 1)
Time.at((t.to_f / sec).floor * sec)
end
|
.host ⇒ Object
120
121
122
|
# File 'lib/app_perf_rpm.rb', line 120
def host
@host ||= Socket.gethostname
end
|
.mutex ⇒ Object
53
54
55
|
# File 'lib/app_perf_rpm.rb', line 53
def mutex
@mutex ||= Mutex.new
end
|
.now ⇒ Object
154
155
156
157
158
159
160
|
# File 'lib/app_perf_rpm.rb', line 154
def now
if defined?(Process::CLOCK_REALTIME)
Process.clock_gettime(Process::CLOCK_REALTIME)
else
Time.now
end
end
|
.round_time(t, sec = 1) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/app_perf_rpm.rb', line 124
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 ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/app_perf_rpm.rb', line 69
def sender
@sender ||= AppPerfRpm::Reporters::JsonClient.new(
url: url,
collector: collector,
flush_interval: config.flush_interval
)
end
|
.tracing? ⇒ Boolean
106
107
108
|
# File 'lib/app_perf_rpm.rb', line 106
def tracing?
!!@tracing
end
|
.tracing_off ⇒ Object
99
100
101
102
103
104
|
# File 'lib/app_perf_rpm.rb', line 99
def tracing_off
mutex.synchronize do
AppPerfRpm.logger.debug "Disabling tracing."
@tracing = false
end
end
|
.tracing_on ⇒ Object
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/app_perf_rpm.rb', line 88
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 ⇒ Object
65
66
67
|
# File 'lib/app_perf_rpm.rb', line 65
def url
@url ||= "#{config.host}/api/listener/3/#{config.license_key}"
end
|
.without_tracing ⇒ Object
110
111
112
113
114
115
116
117
118
|
# File 'lib/app_perf_rpm.rb', line 110
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
|