Module: SystemMetrics

Defined in:
lib/system_metrics.rb,
lib/system_metrics/store.rb,
lib/system_metrics/config.rb,
lib/system_metrics/engine.rb,
lib/system_metrics/version.rb,
lib/system_metrics/collector.rb,
lib/system_metrics/instrument.rb,
lib/system_metrics/middleware.rb,
lib/system_metrics/nested_event.rb,
app/models/system_metrics/metric.rb,
lib/system_metrics/instrument/base.rb,
lib/system_metrics/instrument/rack.rb,
app/helpers/system_metrics/metrics_helper.rb,
lib/system_metrics/instrument/action_view.rb,
lib/system_metrics/instrument/action_mailer.rb,
lib/system_metrics/instrument/active_record.rb,
lib/system_metrics/instrument/action_controller.rb,
app/controllers/system_metrics/metrics_controller.rb,
lib/generators/system_metrics/install/install_generator.rb,
lib/generators/system_metrics/migration/migration_generator.rb

Defined Under Namespace

Modules: Generators, Instrument, MetricsHelper Classes: Collector, Config, Engine, Metric, MetricsController, Middleware, NestedEvent, Store

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.collecting?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/system_metrics.rb', line 17

def collecting?
  Thread.current[:system_metrics_collecting] || false
end

.collection_offObject



13
14
15
# File 'lib/system_metrics.rb', line 13

def self.collection_off
  Thread.current[:system_metrics_collecting] = false
end

.collection_onObject



9
10
11
# File 'lib/system_metrics.rb', line 9

def self.collection_on
  Thread.current[:system_metrics_collecting] = true
end

.without_collectionObject



21
22
23
24
25
26
27
# File 'lib/system_metrics.rb', line 21

def without_collection
  previously_collecting = collecting?
  SystemMetrics.collection_off
  yield if block_given?
ensure
  SystemMetrics.collection_on if previously_collecting
end