Sha256: 29ba86c98d41b80f3d95f0a4946cae3c0d44a8c3ed137abcc4d9c9297688cb10

Contents?: true

Size: 598 Bytes

Versions: 6

Compression:

Stored size: 598 Bytes

Contents

module PlainApm
  module Helpers
    def plain_apm_context(context = {})
      return context unless PlainApm.agent.enabled?
      PlainApm::Extensions::Context.context.merge!(context)
    end

    def plain_apm_instrument(name, context = {}, &block)
      if PlainApm.agent.enabled? && defined?(ActiveSupport::Notifications)
        sanitized_name = name.gsub(/\W/, "_").gsub(/(?!^)([A-Z])/) { |m| "_#{m}" }.squeeze("_").downcase
        ActiveSupport::Notifications.instrument("#{sanitized_name}.manual_plain_apm", **context, &block)
      else
        yield if block
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/helpers.rb
plain_apm-0.10.0 lib/plain_apm/helpers.rb
plain_apm-0.9.8 lib/plain_apm/helpers.rb
plain_apm-0.9.7 lib/plain_apm/helpers.rb
plain_apm-0.9.6 lib/plain_apm/helpers.rb
plain_apm-0.9.5 lib/plain_apm/helpers.rb