Sha256: c7c395e303efabaf7f2d979762c7f38802b497b9a81fc783ccd97da4477c257f

Contents?: true

Size: 982 Bytes

Versions: 11

Compression:

Stored size: 982 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(
          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

11 entries across 11 versions & 1 rubygems

Version Path
newrelic_rpm-5.7.0.350 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-4.8.0.341 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/method_tracer_helpers.rb
newrelic_rpm-4.7.0.339 lib/new_relic/agent/method_tracer_helpers.rb