Sha256: 5c2975d9be6b75052adde99ff73afe4f893050b668be90e86028b1d5d7d21c31

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

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')
            super
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/grape/instrumentation.rb
ddtrace-0.51.0 lib/ddtrace/contrib/grape/instrumentation.rb
ddtrace-0.50.0 lib/ddtrace/contrib/grape/instrumentation.rb