Class: Karafka::Web::Tracking::Producers::Sampler
- Includes:
- Core::Helpers::Time
- Defined in:
- lib/karafka/web/tracking/producers/sampler.rb
Overview
Samples for collecting producers related data we’re interested in
Constant Summary collapse
- SCHEMA_VERSION =
Current schema version This can be used in the future for detecting incompatible changes and writing migrations
'1.1.0'
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#clear ⇒ Object
Clears the sampler (for use after data dispatch).
-
#initialize ⇒ Sampler
constructor
A new instance of Sampler.
-
#track ⇒ Object
We cannot report and track the same time, that is why we use mutex here.
Methods inherited from Sampler
#karafka_core_version, #karafka_version, #karafka_web_version, #librdkafka_version, #process_id, #rdkafka_version, #ruby_version, #waterdrop_version
Constructor Details
#initialize ⇒ Sampler
Returns a new instance of Sampler.
19 20 21 22 23 24 |
# File 'lib/karafka/web/tracking/producers/sampler.rb', line 19 def initialize super @errors = [] @started_at = float_now end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
12 13 14 |
# File 'lib/karafka/web/tracking/producers/sampler.rb', line 12 def errors @errors end |
Instance Method Details
#clear ⇒ Object
Clears the sampler (for use after data dispatch)
38 39 40 |
# File 'lib/karafka/web/tracking/producers/sampler.rb', line 38 def clear @errors.clear end |
#track ⇒ Object
We cannot report and track the same time, that is why we use mutex here. To make sure that samples aggregations and counting does not interact with reporter flushing.
28 29 30 31 32 33 34 35 |
# File 'lib/karafka/web/tracking/producers/sampler.rb', line 28 def track # Prevents deadlocks when something producer related fails in the Web UI reporter return yield(self) if Reporter::MUTEX.owned? Reporter::MUTEX.synchronize do yield(self) end end |