Sha256: 8d0f3ac554810dac0a48c652a8d37a736cd16767f4441fb6b1b85331c497ce39

Contents?: true

Size: 1.31 KB

Versions: 19

Compression:

Stored size: 1.31 KB

Contents

module Instana
  module Helpers
    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 << self

      # Returns a processed javascript snippet to be placed within the HEAD tag of an HTML page.
      #
      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.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
        Instana.logger.debug e.backtrace.join("\r\n")
        return nil
      end

      # Returns a processed javascript snippet to be placed within the HEAD tag of an HTML page.
      # This one is used for testing only
      #
      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.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
        Instana.logger.debug e.backtrace.join("\r\n")
        return nil
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
instana-1.4.9 lib/instana/helpers.rb
instana-1.4.8 lib/instana/helpers.rb
instana-1.4.7 lib/instana/helpers.rb
instana-1.4.6 lib/instana/helpers.rb
instana-1.4.5 lib/instana/helpers.rb
instana-1.4.4 lib/instana/helpers.rb
instana-1.4.2 lib/instana/helpers.rb
instana-1.4.1 lib/instana/helpers.rb
instana-1.4.0 lib/instana/helpers.rb
instana-1.3.3 lib/instana/helpers.rb
instana-1.3.2 lib/instana/helpers.rb
instana-1.3.1 lib/instana/helpers.rb
instana-1.3.0 lib/instana/helpers.rb
instana-1.2.0 lib/instana/helpers.rb
instana-1.1.0 lib/instana/helpers.rb
instana-1.0.3 lib/instana/helpers.rb
instana-1.0.2 lib/instana/helpers.rb
instana-1.0.1 lib/instana/helpers.rb
instana-0.15.0 lib/instana/helpers.rb