Module: ActiveUsage

Defined in:
lib/active_usage.rb,
lib/active_usage/tags.rb,
lib/active_usage/event.rb,
lib/active_usage/store.rb,
lib/active_usage/worker.rb,
lib/active_usage/railtie.rb,
lib/active_usage/tracker.rb,
lib/active_usage/version.rb,
lib/active_usage/recorder.rb,
lib/active_usage/type/tags.rb,
lib/active_usage/middleware.rb,
lib/active_usage/event_queue.rb,
lib/active_usage/adapters/base.rb,
lib/active_usage/adapters/http.rb,
lib/active_usage/configuration.rb,
lib/active_usage/type/sql_queries.rb,
lib/active_usage/window_started_at.rb,
lib/active_usage/instrumentation/subscriber.rb,
lib/active_usage/instrumentation/runtime_state.rb,
lib/active_usage/instrumentation/active_job_hook.rb

Overview

Top-level namespace for the ActiveUsage gem.

Defined Under Namespace

Modules: Adapters, Instrumentation, Type Classes: Configuration, Event, EventQueue, Middleware, Railtie, Recorder, Store, Tags, Tracker, WindowStartedAt, Worker

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configurationObject



37
38
39
# File 'lib/active_usage.rb', line 37

def configuration
  @configuration || @configuration_mutex.synchronize { @configuration ||= Configuration.new }
end

.configure {|configuration| ... } ⇒ Object

Yields:



41
42
43
# File 'lib/active_usage.rb', line 41

def configure
  yield configuration
end

.loggerObject



45
46
47
# File 'lib/active_usage.rb', line 45

def logger
  configuration.logger
end

.record(type:, name:, started_at:, finished_at:, **attributes) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/active_usage.rb', line 49

def record(type:, name:, started_at:, finished_at:, **attributes)
  Recorder.new(
    type: type,
    name: name,
    started_at: started_at,
    finished_at: finished_at,
    tags: tags.current.merge(attributes.delete(:tags) || {}),
    window_started_at: WindowStartedAt.new(finished_at, configuration.window_size).call,
    **attributes
  ).call(store)
end

.storeObject



69
70
71
# File 'lib/active_usage.rb', line 69

def store
  @store || @store_mutex.synchronize { @store ||= Store.new(configuration.adapter) }
end

.tagsObject



65
66
67
# File 'lib/active_usage.rb', line 65

def tags
  @tags || @tags_mutex.synchronize { @tags ||= Tags.new(configuration.tags) }
end

.track(name, tags: {}) ⇒ Object



61
62
63
# File 'lib/active_usage.rb', line 61

def track(name, tags: {}, &)
  Tracker.new(name, tags).call(&)
end