Skip to content

Commit

Permalink
Add ENV variable and HTTP header triggers for tracing.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Nov 7, 2014
1 parent 17ed55e commit e2c27f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ the code.
- `QAFOO_PROFILER_SAMPLERATE` controls the sample rate how often the profiler should sample full XHProf traces.
- `QAFOO_PROFILER_ENABLE_LAYERS` controls if XHProf should sample wall times of layers (DB, I/O, ...) in every request.
- `QAFOO_PROFILER_ENABLE_ARGUMENTS` controls if argument summaries of important functions such as DB, HTTP and filesystem calls should be traced.
- `QAFOO_PROFILER_DISABLE_SESSIONS` controls if explicit developer sessions are allowed.

For example you can configure this in your PHP FPM Pool configuration:

env[QAFOO_PROFILER_DISABLED] = 0
env[QAFOO_PROFILER_SAMPLERATE] = 10
env[QAFOO_PROFILER_ENABLE_LAYERS] = 1
env[QAFOO_PROFILER_ENABLE_ARGUMENTS] = 1
env[QAFOO_PROFILER_DISABLE_SESSIONS] = 0

### Framework Detection

Expand Down
11 changes: 10 additions & 1 deletion src/main/QafooLabs/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,21 @@ private static function decideProfiling($treshold)
}

$vars = array();
if (isset($_COOKIE['QAFOO_PROFILER_SESSION']) && is_string($_COOKIE['QAFOO_PROFILER_SESSION'])) {

if (isset($_SERVER['HTTP_X_QAFOO_PROFILER']) && is_string($_SERVER['HTTP_X_QAFOO_PROFILER'])) {
parse_str($_SERVER['HTTP_X_QAFOO_PROFILER'], $vars);
} else if (isset($_SERVER['QAFOO_PROFILER_SESSION']) && is_string($_SERVER['QAFOO_PROFILER_SESSION'])) {
parse_str($_SERVER['QAFOO_PROFILER_SESSION'], $vars);
} else if (isset($_COOKIE['QAFOO_PROFILER_SESSION']) && is_string($_COOKIE['QAFOO_PROFILER_SESSION'])) {
parse_str($_COOKIE['QAFOO_PROFILER_SESSION'], $vars);
} else if (isset($_GET['_qprofiler']) && is_array($_GET['_qprofiler'])) {
$vars = $_GET['_qprofiler'];
}

if (isset($_SERVER['QAFOO_PROFILER_DISABLE_SESSIONS']) && $_SERVER['QAFOO_PROFILER_DISABLE_SESSIONS']) {
$vars = array();
}

if (isset($vars['hash'], $vars['time'], $vars['user'], $vars['method'])) {
$message = 'method=' . $vars['method'] . '&time=' . $vars['time'] . '&user=' . $vars['user'];

Expand Down

0 comments on commit e2c27f9

Please sign in to comment.