Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Add methods to proxy for tideways_span_watch/tideways_span_callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed May 31, 2015
1 parent d661817 commit 0a7bc7a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/main/Tideways/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,40 @@ public static function setCustomVariable($name, $value)
self::$currentRootSpan->annotate(array($name => $value));
}

/**
* Watch a function for calls and create timeline spans around it.
*
* @param string $function
* @param string $category
*/
public static function watch($function, $category = null)
{
if (self::$extension === self::EXTENSION_TIDEWAYS) {
tideways_span_watch($function, $category);
}
}

/**
* Watch a function and invoke a callback when its called.
*
* To start a span, call {@link \Tideways\Profiler::createSpan($category)}
* inside the callback and return {$span->getId()}:
*
* @example
*
* \Tideways\Profiler::watchCallback('mysql_query', function ($context) {
* $span = \Tideways\Profiler::createSpan('sql');
* $span->annotate(array('title' => $context['args'][0]));
* return $span->getId();
* });
*/
public static function watchCallback($function, $callback)
{
if (self::$extension === self::EXTENSION_TIDEWAYS) {
tideways_span_callback($function, $callback);
}
}

/**
* Create a new trace span with the given category name.
*
Expand Down

0 comments on commit 0a7bc7a

Please sign in to comment.