You are here

function statsd_exit in StatsD 7

Same name and namespace in other branches
  1. 6 statsd.module \statsd_exit()
  2. 7.2 statsd.module \statsd_exit()

Implements hook_exit().

File

./statsd.module, line 77

Code

function statsd_exit($destination = NULL) {
  if (variable_get('statsd_user_events', TRUE)) {
    $active_sessions = db_query("SELECT count(*) as num FROM {sessions} WHERE timestamp > UNIX_TIMESTAMP() - 3600")
      ->fetchField();
    statsd_call('user_events.active_sessions', 'gauge', $active_sessions);
    statsd_call('user_events.page_view');
  }
  if (variable_get('statsd_performance_events', TRUE)) {
    $memory = round(memory_get_peak_usage() / 1024 / 1024, 2);
    statsd_call('performance_events.peak_memory', 'gauge', $memory);
    $start =& drupal_static('statsd_timer');

    // hook_boot() may not be called in certain contexts.
    if ($start > 0) {
      $end = microtime(TRUE);
      $time = round(($end - $start) * 1000, 0);
      statsd_call('performance_events.execution_time', 'timing', $time);
    }
  }
}