instrument method

InstrumentTiming instrument(
  1. IContext? context,
  2. String name
)

Adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement.

  • context (optional) a context to trace execution through call chain.
  • name a method name. Returns InstrumentTiming object to end the time measurement.

Implementation

InstrumentTiming instrument(IContext? context, String name) {
  logger.trace(context, 'Executing %s method', [name]);
  counters.incrementOne('$name.exec_count');

  var counterTiming = counters.beginTiming('$name.exec_time');
  var traceTiming = tracer.beginTrace(context, name, '');

  return InstrumentTiming(
      context, name, 'exec', logger, counters, counterTiming, traceTiming);
}