Sha256: b2adb75e95a07256af04f40c456c67be2b75f2a53a11484672737fcbaddbd6fa

Contents?: true

Size: 927 Bytes

Versions: 40

Compression:

Stored size: 927 Bytes

Contents

require 'ddtrace/ext/http'
require 'ddtrace/contrib/sinatra/ext'

module Datadog
  module Contrib
    module Sinatra
      # Gets and sets trace information from a Rack Env
      module Env
        module_function

        def datadog_span(env)
          env[Ext::RACK_ENV_REQUEST_SPAN]
        end

        def set_datadog_span(env, span)
          env[Ext::RACK_ENV_REQUEST_SPAN] = span
        end

        def request_header_tags(env, headers)
          headers ||= []

          {}.tap do |result|
            headers.each do |header|
              rack_header = header_to_rack_header(header)
              if env.key?(rack_header)
                result[Datadog::Ext::HTTP::RequestHeaders.to_tag(header)] = env[rack_header]
              end
            end
          end
        end

        def header_to_rack_header(name)
          "HTTP_#{name.to_s.upcase.gsub(/[-\s]/, '_')}"
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
ls-trace-0.1.2 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.34.2 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.34.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.34.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.33.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.33.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.32.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.31.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.31.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.30.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.30.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.29.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.26.1 lib/ddtrace/contrib/sinatra/env.rb
ls-trace-0.1.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.29.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.28.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.27.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.26.0 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.25.1 lib/ddtrace/contrib/sinatra/env.rb
ddtrace-0.25.0 lib/ddtrace/contrib/sinatra/env.rb