Sha256: a4b70bc71e67f053bad82af49c23fd302194deb36f5030a40b343b083b019d0d

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 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::TransactionState.tl_get
        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::Transaction.start_segment first_name, metric_names
        if options[:metric] == false
          segment.record_metrics = false
        end

        begin
          yield
        ensure
          segment.finish
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newrelic_rpm-4.4.0.336 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-4.3.0.335 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-4.2.0.334 lib/new_relic/agent/method_tracer_helpers.rb