Module: Instana::Helpers

Defined in:
lib/instana/helpers.rb

Constant Summary collapse

EUM_SNIPPET =
(File.read(File.dirname(__FILE__) + '/eum/eum.js.erb')).freeze
EUM_TEST_SNIPPET =
(File.read(File.dirname(__FILE__) + '/eum/eum-test.js.erb')).freeze

Class Method Summary collapse

Class Method Details

.eum_snippet(api_key, kvs = {}) ⇒ Object

Returns a processed javascript snippet to be placed within the HEAD tag of an HTML page.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/instana/helpers.rb', line 10

def eum_snippet(api_key, kvs = {})
  return nil if !::Instana.tracer.tracing?

  ::Instana.config[:eum_api_key] = api_key
  ::Instana.config[:eum_baggage] = kvs

  ERB.new(EUM_SNIPPET).result
rescue => e
  Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
  Instana.logger.debug { e.backtrace.join("\r\n") }
  return nil
end

.eum_test_snippet(api_key, kvs = {}) ⇒ Object

Returns a processed javascript snippet to be placed within the HEAD tag of an HTML page. This one is used for testing only



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/instana/helpers.rb', line 26

def eum_test_snippet(api_key, kvs = {})
  return nil if !::Instana.tracer.tracing?

  ::Instana.config[:eum_api_key] = api_key
  ::Instana.config[:eum_baggage] = kvs

  ERB.new(EUM_TEST_SNIPPET).result
rescue => e
  Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
  Instana.logger.debug { e.backtrace.join("\r\n") }
  return nil
end