Module: Telltale

Defined in:
lib/telltale.rb,
lib/telltale/data.rb,
lib/telltale/railtie.rb

Defined Under Namespace

Classes: Data, Railtie

Class Method Summary collapse

Class Method Details

.clientObject



34
35
36
# File 'lib/telltale.rb', line 34

def client
  OpenTSDB::Client.new(hostname: opentsdb_host, port: opentsdb_port)
end

.configure_request_instrumentationObject



15
16
17
18
19
20
# File 'lib/telltale.rb', line 15

def configure_request_instrumentation
  ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |_name, started, finished, _unique_id, payload|
    next unless report?
    client.put Telltale::Data.compile(started, finished, payload)
  end
end

.opentsdb_hostObject



30
31
32
# File 'lib/telltale.rb', line 30

def opentsdb_host
  ENV['TELLTALE_OPENTSDB_HOST']
end

.opentsdb_portObject



26
27
28
# File 'lib/telltale.rb', line 26

def opentsdb_port
  ENV['TELLTALE_OPENTSDB_PORT'] || 4242
end

.report?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/telltale.rb', line 22

def report?
  opentsdb_host.present? && !Rails.env.test?
end

.setup!Object



6
7
8
9
10
11
12
13
# File 'lib/telltale.rb', line 6

def setup!
  if report?
    configure_request_instrumentation
    Rails.logger.info "Telltale started, will report to #{opentsdb_host} on port #{opentsdb_port}"
  else
    Rails.logger.error 'TELLTALE_OPENTSDB_HOST not set. Telltale will not report to OpenTSDB.'
  end
end