Class: TingYun::Agent::Collector::TransactionSampler
- Inherits:
-
Object
- Object
- TingYun::Agent::Collector::TransactionSampler
show all
- Extended by:
- ClassMethod
- Defined in:
- lib/ting_yun/agent/collector/transaction_sampler.rb,
lib/ting_yun/agent/collector/transaction_sampler/class_method.rb,
lib/ting_yun/agent/collector/transaction_sampler/slowest_sample_buffer.rb,
lib/ting_yun/agent/collector/transaction_sampler/transaction_sample_buffer_base.rb
Defined Under Namespace
Modules: ClassMethod
Classes: SlowestSampleBuffer, TransactionSampleBufferBase
Constant Summary
Constants included
from ClassMethod
ClassMethod::MAX_DATA_LENGTH
Instance Attribute Summary collapse
Instance Method Summary
collapse
action_tracer_segment, add_node_info, append_backtrace, notice_nosql, notice_nosql_statement, notice_pop_frame, notice_push_frame, notice_sql, on_start_transaction, tl_builder, truncate_message
Constructor Details
Returns a new instance of TransactionSampler.
Instance Attribute Details
#last_sample ⇒ Object
Returns the value of attribute last_sample.
16
17
18
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 16
def last_sample
@last_sample
end
|
Instance Method Details
#harvest! ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 25
def harvest!
return [] unless TingYun::Agent.config[:'nbs.action_tracer.enabled']
samples = @lock.synchronize do
@last_sample = nil
harvest_from_sample_buffers
end
prepare_samples(samples)
end
|
#harvest_from_sample_buffers ⇒ Object
35
36
37
38
39
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 35
def harvest_from_sample_buffers
result = []
@sample_buffers.each { |buffer| result.concat(buffer.harvest_samples) }
result.uniq
end
|
#merge!(previous) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 52
def merge!(previous)
@lock.synchronize do
@sample_buffers.each do |buffer|
buffer.store_previous(previous)
end
end
end
|
#on_finishing_transaction(state, txn, time = Time.now.to_f) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 65
def on_finishing_transaction(state, txn, time=Time.now.to_f)
last_builder = state.transaction_sample_builder
return unless last_builder && TingYun::Agent.config[:'nbs.action_tracer.enabled']
last_builder.finish_trace(time)
final_trace = last_builder.trace
final_trace.attributes = txn.attributes
@lock.synchronize do
@last_sample = final_trace
store_sample(@last_sample)
@last_sample
end
end
|
#prepare_samples(samples) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 40
def prepare_samples(samples)
samples.select do |sample|
begin
sample.prepare_to_send!
rescue => e
TingYun::Agent.logger.error('Failed to prepare transaction trace. Error: ', e)
false
else
true
end
end
end
|
#reset! ⇒ Object
59
60
61
62
63
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 59
def reset!
@lock.synchronize do
@sample_buffers.each { |sample| sample.reset! }
end
end
|
#store_sample(sample) ⇒ Object
82
83
84
85
86
|
# File 'lib/ting_yun/agent/collector/transaction_sampler.rb', line 82
def store_sample(sample)
@sample_buffers.each do |sample_buffer|
sample_buffer.store(sample)
end
end
|