Sha256: 05411702c6a721c761114209823a1b1d11dcb8c0554e22f5ad78eb6755008f6b

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# typed: ignore

module Datadog
  module AppSec
    module Contrib
      # Instrument Sinatra.
      module Sinatra
        # Sinatra framework code, used to essentially:
        # - handle configuration entries which are specific to Datadog tracing
        # - instrument parts of the framework when needed
        module Framework
          # Configure Rack from Sinatra, but only if Rack has not been configured manually beforehand
          def self.setup
            Datadog::AppSec.configure do |datadog_config|
              sinatra_config = config_with_defaults(datadog_config)
              activate_rack!(datadog_config, sinatra_config)
            end
          end

          def self.config_with_defaults(datadog_config)
            datadog_config[:sinatra]
          end

          # Apply relevant configuration from Sinatra to Rack
          def self.activate_rack!(datadog_config, sinatra_config)
            datadog_config.instrument(
              :rack,
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/appsec/contrib/sinatra/framework.rb