Sha256: 0991c203bc0fae814c064e49d2d5cc7f4f33d2b7768b206df796189262633432

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

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.

# This test is based on the example code at:
# https://docs.newrelic.com/docs/ruby/ruby-custom-metric-collection#example_class
# 
# See https://newrelic.atlassian.net/browse/RUBY-1116 for details on how this
# was broken previously.

require 'new_relic/agent/method_tracer' 

class StandaloneInstrumentationTest < MiniTest::Unit::TestCase
  class InstrumentedClass
    def instance_method(*args)
      args
    end

    def self.class_method(*args)
      args
    end

    include NewRelic::Agent::MethodTracer
    add_method_tracer :instance_method

    class << self
      include ::NewRelic::Agent::MethodTracer
      add_method_tracer :class_method
    end
  end

  def test_instance_method_tracers_should_not_cause_errors
    args = [1, 2, 3]
    result = InstrumentedClass.new.instance_method(*args)
    assert_equal(args, result)
  end

  def test_class_method_tracer_should_not_cause_errors
    args = [1, 2, 3]
    result = InstrumentedClass.class_method(*args)
    assert_equal(args, result)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.2.195 test/multiverse/suites/bare/standalone_instrumentation_test.rb
newrelic_rpm-3.7.2.192 test/multiverse/suites/bare/standalone_instrumentation_test.rb
newrelic_rpm-3.7.2.190.beta test/multiverse/suites/bare/standalone_instrumentation_test.rb