Sha256: 221488aef4a599f855e02c16c1a7db2a9f6bd4e9322653bf99a0d76f0b648ce7

Contents?: true

Size: 966 Bytes

Versions: 9

Compression:

Stored size: 966 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module MethodTracerHelpers
      MAX_ALLOWED_METRIC_DURATION = 1_000_000_000 # roughly 31 years

      extend self

      def trace_execution_scoped(metric_names, options={}) #THREAD_LOCAL_ACCESS
        state = NewRelic::Agent::Tracer.state
        return yield unless state.is_execution_traced?

        metric_names = Array(metric_names)
        first_name   = metric_names.shift
        return yield unless first_name

        segment = NewRelic::Agent::Tracer.start_segment(
          name: first_name,
          unscoped_metrics: metric_names
        )

        if options[:metric] == false
          segment.record_metrics = false
        end

        begin
          yield
        ensure
          segment.finish if segment
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
newrelic_rpm-6.8.0.360 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.7.0.359 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.6.0.358 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.5.0.357 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.4.0.356 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.3.0.355 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.2.0.354 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/method_tracer_helpers.rb