Sha256: b9d549022a2b53584e49922f7e1a4c9a19fd1083f69ccbb8afdbbc8341f82ff9

Contents?: true

Size: 1.06 KB

Versions: 20

Compression:

Stored size: 1.06 KB

Contents

module Skylight
  module Normalizers
    module Grape
      class EndpointRun < Endpoint
        register "endpoint_run.grape"

        def normalize(trace, _name, payload)
          trace.endpoint = get_endpoint_name(payload[:endpoint]) if payload[:endpoint]

          # We don't necessarily want this to be all instrumented since it's fairly internal.
          # However, it is a good place to get the endpoint name.
          :skip
        end

        private

        def get_endpoint_name(endpoint)
          method = get_method(endpoint)
          path = get_path(endpoint)
          namespace = get_namespace(endpoint)

          if namespace && !namespace.empty?
            path = "/#{path}" if path[0] != "/"
            path = "#{namespace}#{path}"
          end

          "#{base_app_name(endpoint)} [#{method}] #{path}".strip
        end

        def base_app_name(endpoint)
          ep = endpoint.options[:for]
          return ep.name if ep.name

          ep.base.name if ep.respond_to?(:base) && ep.base.respond_to?(:name)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
skylight-6.1.0.beta lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.4 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.3 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.3.5 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.2 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.1 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.0 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.0.beta2 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-6.0.0.beta lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.3.4 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.3.3 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.3.2 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.3.1 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.3.0 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.2.0 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.2.0.beta2 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.2.0.beta lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.1.1 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.1.0.beta3 lib/skylight/normalizers/grape/endpoint_run.rb
skylight-5.1.0.beta2 lib/skylight/normalizers/grape/endpoint_run.rb