Sha256: b8de9f91ddd1a7bd464bd7aae885d8d0040ac92610c3c9fd3b5391437dfa2540

Contents?: true

Size: 898 Bytes

Versions: 8

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

module Labkit
  module Tracing
    module Rails
      module ActiveRecord
        # For more information on the payloads: https://guides.rubyonrails.org/active_support_instrumentation.html
        class SqlInstrumenter < AbstractInstrumenter
          OPERATION_NAME_PREFIX = "active_record:"
          DEFAULT_OPERATION_NAME = "sqlquery"

          def span_name(payload)
            OPERATION_NAME_PREFIX + (payload[:name].presence || DEFAULT_OPERATION_NAME)
          end

          def tags(payload)
            {
              "component" => COMPONENT_TAG,
              "span.kind" => "client",
              "db.type" => "sql",
              "db.connection_id" => payload[:connection_id],
              "db.cached" => payload[:cached] || false,
              "db.statement" => payload[:sql],
            }
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gitlab-labkit-0.13.2 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.13.1 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.13.0 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.12.2 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.12.1 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.12.0 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.11.0 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
gitlab-labkit-0.10.1 lib/labkit/tracing/rails/active_record/sql_instrumenter.rb