Skip to content

Instantly share code, notes, and snippets.

@gnarg
Created June 22, 2012 20:10
Show Gist options
  • Select an option

  • Save gnarg/2974899 to your computer and use it in GitHub Desktop.

Select an option

Save gnarg/2974899 to your computer and use it in GitHub Desktop.
Agent Instrumentation
defined?(ModuleToInstrument) && ModuleToInstrument.respond_to?(:method_to_decorate)
/* internal functions */
wraprec->oldhandler = ((zend_internal_function *) orig_func)->handler;
((zend_internal_function *) orig_func)->handler = wraprec->wrapper;
wraprec->is_wrapped = 1;
/* user functions */
nr_per_process_globals.orig_execute = zend_execute;
zend_execute = nr__execute;
HRESULT Profiler::JITCompilationStarted(FunctionID functionID, BOOL /*fIsSafeToBlock*/)
public byte[] transform(ClassLoader loader, String className,
Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
byte[] classfileBuffer) throws IllegalClassFormatException
var mthd_without_newrelic_instrumentaiton = shimmer.preserveMethod(Module, 'mthd');
Module.mthd = mthd_with_newrelic_instrumentation;
mthd_with_newrelic_instrumentation = FunctionTraceWrapper(mthd)
setattr(module, mthd, mthd_with_newrelic_instrumentation)
alias_method :mthd_without_newrelic_instrumentation, :mthd
alias_method :mthd, :mthd_with_newrelic_instrumentation
# decorative prefix
start = Time.now
begin
# the code under instrumentation
# decorative postfix
ensure
stop = Time.now
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment