So how exactly do you expect the "system administrator" to indicate which
method he wants wrapped? Somewhere it would appear that they would need to
declare the class/method desired.

Now for a second take your New Relic example and think just an inch outside
of the box

File A.rb

class Foo
  def generate_image
    ...
  end
end

New file Wrappers.rb written by the system administrator to use your tool

require 'my_great_new_tool'
class Foo
  include ::MyGreatNewTool::Wrapper

  add_wrapper :generate_image, "Hi kids"
end

Well look at that - I haven't touched A.rb but I've just wrapped my proc.
And of course it could be as simple as a config file that listed
Foo::generate_image as the method that wrapping was desired for and then
your tool could wrap without them writing Wrappers.rb but that's another
exercise.

But somewhere the end user has to tell you what they want wrapped and there
is no reason why you can't wrap the methods outside of the original source
code.

John



On Wed, Mar 5, 2014 at 8:52 AM, Martin Ennemoser <lists / ruby-forum.com>wrote:

> I have already looked at how New Relic does that: They do it pretty the
> same way that Robert Klemme described above. You have to change the Ruby
> source code if you want to instrument a method. Here is an example:
>
> require 'new_relic/agent/method_tracer'
> class Foo
>   include ::NewRelic::Agent::MethodTracer
>
>   def generate_image
>     ...
>   end
>
>   add_method_tracer :generate_image, 'Custom/generate_image'
> end
>
> So this does not help me a lot.
>
> --
> Posted via http://www.ruby-forum.com/.
>