Sha256: c781101abe552b3b56011f5ca0182066ca093fb1404aafb7dcd32e9f5be20bfe

Contents?: true

Size: 1.31 KB

Versions: 37

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.info "#{__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.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
        Instana.logger.debug e.backtrace.join("\r\n")
        return nil
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
instana-1.7.10 lib/instana/helpers.rb
instana-1.7.9 lib/instana/helpers.rb
instana-1.7.8 lib/instana/helpers.rb
instana-1.7.7 lib/instana/helpers.rb
instana-1.7.6 lib/instana/helpers.rb
instana-1.7.5 lib/instana/helpers.rb
instana-1.7.4 lib/instana/helpers.rb
instana-1.7.3 lib/instana/helpers.rb
instana-1.7.2 lib/instana/helpers.rb
instana-1.7.1 lib/instana/helpers.rb
instana-1.7.0 lib/instana/helpers.rb
instana-1.6.1 lib/instana/helpers.rb
instana-1.6.0 lib/instana/helpers.rb
instana-1.5.2 lib/instana/helpers.rb
instana-1.5.1 lib/instana/helpers.rb
instana-1.5.0 lib/instana/helpers.rb
instana-1.4.11 lib/instana/helpers.rb