Sha256: fce72f9ba2a50fe95a5ba9420cfaf204e7eec8162704419cb4b99c17373e5619

Contents?: true

Size: 1.43 KB

Versions: 33

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Labkit
  module Tracing
    module Rails
      module ActiveSupport
        # ActiveSupport bridges action active support notifications to
        # the distributed tracing subsystem
        class Subscriber
          include Labkit::Tracing::TracingCommon

          CACHE_READ_TOPIC = "cache_read.active_support"
          CACHE_GENERATE_TOPIC = "cache_generate.active_support"
          CACHE_FETCH_HIT_TOPIC = "cache_fetch_hit.active_support"
          CACHE_WRITE_TOPIC = "cache_write.active_support"
          CACHE_DELETE_TOPIC = "cache_delete.active_support"

          # Instruments Rails ActiveSupport events for opentracing.
          # Returns a lambda, which, when called will unsubscribe from the notifications
          def self.instrument
            subscriptions = [
              ::ActiveSupport::Notifications.subscribe(CACHE_READ_TOPIC, CacheReadInstrumenter.new),
              ::ActiveSupport::Notifications.subscribe(CACHE_GENERATE_TOPIC, CacheGenerateInstrumenter.new),
              ::ActiveSupport::Notifications.subscribe(CACHE_FETCH_HIT_TOPIC, CacheFetchHitInstrumenter.new),
              ::ActiveSupport::Notifications.subscribe(CACHE_WRITE_TOPIC, CacheWriteInstrumenter.new),
              ::ActiveSupport::Notifications.subscribe(CACHE_DELETE_TOPIC, CacheDeleteInstrumenter.new),
            ]

            create_unsubscriber subscriptions
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
gitlab-labkit-0.37.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.36.1 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.36.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.35.1 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.35.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.34.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.33.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.32.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.31.1 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.31.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.30.1 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.30.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.29.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.28.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.27.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.26.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.25.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.24.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.23.0 lib/labkit/tracing/rails/active_support/subscriber.rb
gitlab-labkit-0.22.0 lib/labkit/tracing/rails/active_support/subscriber.rb