You are here

function statsd_exit in StatsD 6

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

Implementation of hook_exit()

File

./statsd.module, line 69

Code

function statsd_exit($destination = NULL) {
  if (variable_get('statsd_user_events', TRUE)) {
    $active_sessions = db_result(db_query("SELECT count(*) as num FROM {sessions} WHERE timestamp > UNIX_TIMESTAMP() - 3600"));
    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 = 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);
    }
  }
}