Module: OneApm::Collector::StatsEngine::GCProfiler
- Defined in:
- lib/one_apm/collector/stats_engine/gc_profiler.rb
Defined Under Namespace
Classes: CoreGCProfiler, GCSnapshot, RailsBenchProfiler
Constant Summary
collapse
- OA_GC_ROLLUP =
'GC/Transaction/all'.freeze
- OA_GC_OTHER =
'GC/Transaction/allOther'.freeze
- OA_GC_WEB =
'GC/Transaction/allWeb'.freeze
Class Method Summary
collapse
Class Method Details
.gc_metric_name ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/one_apm/collector/stats_engine/gc_profiler.rb', line 57
def self.gc_metric_name
if OneApm::Transaction.recording_web_transaction?
OA_GC_WEB
else
OA_GC_OTHER
end
end
|
.init ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/one_apm/collector/stats_engine/gc_profiler.rb', line 9
def self.init
return @profiler if @initialized
@profiler = if RailsBenchProfiler.enabled?
RailsBenchProfiler.new
elsif CoreGCProfiler.enabled?
CoreGCProfiler.new
end
@initialized = true
@profiler
end
|
.record_delta(start_snapshot, end_snapshot) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/one_apm/collector/stats_engine/gc_profiler.rb', line 34
def self.record_delta(start_snapshot, end_snapshot)
if @profiler && start_snapshot && end_snapshot
elapsed_gc_time_s = end_snapshot.gc_time_s - start_snapshot.gc_time_s
num_calls = end_snapshot.gc_call_count - start_snapshot.gc_call_count
record_gc_metric(num_calls, elapsed_gc_time_s)
@profiler.reset
elapsed_gc_time_s
end
end
|
.record_gc_metric(call_count, elapsed) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/one_apm/collector/stats_engine/gc_profiler.rb', line 45
def self.record_gc_metric(call_count, elapsed)
OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(gc_metric_name, OA_GC_ROLLUP) do |stats|
stats.call_count += call_count
stats.total_call_time += elapsed
stats.total_exclusive_time += elapsed
end
end
|
.reset ⇒ Object
20
21
22
23
|
# File 'lib/one_apm/collector/stats_engine/gc_profiler.rb', line 20
def self.reset
@profiler = nil
@initialized = nil
end
|
.take_snapshot ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/one_apm/collector/stats_engine/gc_profiler.rb', line 25
def self.take_snapshot
init
if @profiler
GCSnapshot.new(@profiler.call_time_s, @profiler.call_count)
else
nil
end
end
|