HomePhorge

Instrumentation foundation layer
b743b4d84e8aUnpublished

Unpublished Commit · Learn More

Repository Importing: This repository is still importing.

Description

Instrumentation foundation layer

This is the base of the instrumentation layer.
The idea is to allow instrumentation of code blocks.
Each time this code is executed an event is fired to some event
listeners that in turn can do whatever is needed to perform the instrumentation.

This patch adds:

  • code instrumentation calls
  • the listener system

Listeners are added by adding a file to puppet/util/instrumentation/listeners
containing:

Puppet::Util::Instrumentation.new_listener(:my_instrumentation, pattern) do

def notify(label, event, data)
  ... do something for data...
end

end

It is possible to use a "pattern". The listener will be notified only
if the pattern match the label of the event.
The pattern can be a symbol, a string or a regex.
If no pattern is provided, then the listener will be notified for every
event.

The notify method will be called before and after the insturmented code
is executed, with respectively an event of :start and then :stop.

This class is thread-safe.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>

Event Timeline

Brice Figureau <brice-puppet@daysofwonder.com> committed rPUb743b4d84e8a: Instrumentation foundation layer (authored by Brice Figureau <brice-puppet@daysofwonder.com>).Dec 21 2011, 8:11 PM