You are here

function performance_views_data in Performance Logging and Monitoring 7

Same name and namespace in other branches
  1. 6.2 includes/performance.views.inc \performance_views_data()
  2. 6 includes/performance.views.inc \performance_views_data()
  3. 7.2 includes/performance.views.inc \performance_views_data()

Implementation of hook_views_data().

File

includes/performance.views.inc, line 6

Code

function performance_views_data() {

  // The 'group' index will be used as a prefix in the UI for any of this
  // table's fields, sort criteria, etc. so it's easy to tell where they came
  // from.
  // Find it a bit silly in the performance logging context but it's mandatory.
  $data['performance_summary']['table']['group'] = t('Performance logging summary');

  // Define this as a base table.
  $data['performance_summary']['table']['base'] = array(
    'field' => 'path',
    'title' => t('Performance logging summary'),
    'weight' => -10,
  );

  // Path field.
  $data['performance_summary']['path'] = array(
    'title' => t('Path'),
    'help' => t('The path of the page for which summary performance logging was stored.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  // Last access field.
  $data['performance_summary']['last_access'] = array(
    'title' => t('Last access'),
    'help' => t('Timestamp of when this page was last accessed.'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
  );

  // Max. mem consumed field.
  $data['performance_summary']['bytes_max'] = array(
    'title' => t('Bytes max.'),
    'help' => t('Maximum amount of memory consumed in bytes when rendering the page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Avg. mem consumed field.
  $data['performance_summary']['bytes_avg'] = array(
    'title' => t('Bytes avg.'),
    'help' => t('Average amount of memory consumed in bytes when rendering the page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Max milliseconds field.
  $data['performance_summary']['ms_max'] = array(
    'title' => t('Milliseconds max'),
    'help' => t('Maximum amount of milliseconds needed to render this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Avg. milliseconds field.
  $data['performance_summary']['ms_avg'] = array(
    'title' => t('Milliseconds avg'),
    'help' => t('Average amount of milliseconds needed to render this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Max query count field.
  $data['performance_summary']['query_count_max'] = array(
    'title' => t('Query count max'),
    'help' => t('Maximum amount of queries executed when rendering this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Avg. query count field.
  $data['performance_summary']['query_count_avg'] = array(
    'title' => t('Query count avg'),
    'help' => t('Average amount of queries executed when rendering this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Max query timer field.
  $data['performance_summary']['query_timer_max'] = array(
    'title' => t('Query timer max'),
    'help' => t('Maximum amount of milliseconds spent on queries for this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Avg. query timer field.
  $data['performance_summary']['query_timer_avg'] = array(
    'title' => t('Query timer avg'),
    'help' => t('Average amount of milliseconds spent on queries for this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Number of accesses field.
  $data['performance_summary']['num_accesses'] = array(
    'title' => t('Number of accesses'),
    'help' => t('Number of times this page has been accessed.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // The 'group' index will be used as a prefix in the UI for any of this
  // table's fields, sort criteria, etc. so it's easy to tell where they came
  // from.
  // Find it a bit silly in the performance logging context but it's mandatory.
  $data['performance_detail']['table']['group'] = t('Performance logging details');
  $data['performance_detail']['table']['base'] = array(
    'field' => 'pid',
    'title' => t('Performance logging details'),
    'weight' => -10,
  );

  // Path ID field.
  $data['performance_detail']['pid'] = array(
    'title' => t('Path ID'),
    'help' => t('Serialised ID field.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Last access field.
  $data['performance_detail']['timestamp'] = array(
    'title' => t('Timestamp'),
    'help' => t('Time when this data was recorded.'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
  );

  // Bytes field.
  $data['performance_detail']['bytes'] = array(
    'title' => t('Bytes'),
    'help' => t('Amount of memory consumed in bytes when rendering the page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Bytes field.
  $data['performance_detail']['ms'] = array(
    'title' => t('Milliseconds'),
    'help' => t('Amount of milliseconds needed to render this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Query count field.
  $data['performance_detail']['query_count'] = array(
    'title' => t('Query count'),
    'help' => t('Amount of queries executed when rendering this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Query timer field.
  $data['performance_detail']['query_timer'] = array(
    'title' => t('Query timer'),
    'help' => t('Amount of milliseconds spent on queries for this page.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Anonymous user field.
  $data['performance_detail']['anon'] = array(
    'title' => t('Anonymous user?'),
    'help' => t('Whether the access was by an anonymous user or not.'),
    'field' => array(
      'handler' => 'views_handler_field_boolean',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_boolean_operator',
      'label' => t('Anonymous?'),
      'type' => 'yes-no',
      // use boolean_field = 1 instead of boolean_field <> 0 in WHERE statment
      'use equal' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Path field.
  $data['performance_detail']['path'] = array(
    'title' => t('Path'),
    'help' => t('The path of the page for which detailed performance logging was stored.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );
  return $data;
}