Sha256: adf6bb2067e0682714a305cda9b38d1569ac55d8ec30c5c166c1143272eb2617

Contents?: true

Size: 943 Bytes

Versions: 5

Compression:

Stored size: 943 Bytes

Contents

# typed: false
module Datadog
  module Contrib
    module Grape
      # Instrumentation for Grape::Endpoint
      module Instrumentation
        def self.included(base)
          base.singleton_class.prepend(ClassMethods)
          base.prepend(InstanceMethods)
        end

        # ClassMethods - implementing instrumentation
        module ClassMethods
          def generate_api_method(*params, &block)
            method_api = super

            proc do |*args|
              ::ActiveSupport::Notifications.instrument('endpoint_render.grape.start_render')
              method_api.call(*args)
            end
          end
        end

        # InstanceMethods - implementing instrumentation
        module InstanceMethods
          def run(*args)
            ::ActiveSupport::Notifications.instrument('endpoint_run.grape.start_process', endpoint: self, env: env)
            super
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.54.2 lib/ddtrace/contrib/grape/instrumentation.rb
ddtrace-0.54.1 lib/ddtrace/contrib/grape/instrumentation.rb
ddtrace-0.54.0 lib/ddtrace/contrib/grape/instrumentation.rb
ddtrace-0.53.0 lib/ddtrace/contrib/grape/instrumentation.rb
ddtrace-0.52.0 lib/ddtrace/contrib/grape/instrumentation.rb