Plugin Directory

Changeset 2187003


Ignore:
Timestamp:
11/06/2019 01:59:48 PM (6 years ago)
Author:
rossigee
Message:

Add 'site' and 'variant' metrics tags.

Location:
web-request-metrics/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • web-request-metrics/trunk/readme.txt

    r2175931 r2187003  
    55* Requires at least: 4.7.2
    66* Tested up to: 5.3.0
    7 * Stable tag: 0.2.4
     7* Stable tag: 0.3.0
    88* License: GPLv2
    99
     
    3535== Changelog ==
    3636
     37= 0.3.0 =
     38
     39* Add 'site' and 'variant' metrics tags.
     40
    3741= 0.2.4 =
    3842
  • web-request-metrics/trunk/web-request-metrics-options.php

    r1967574 r2187003  
    5252</table>
    5353
     54<h3>Site tags</h3>
     55
     56<p>Extra tags to help group sites (i.e. 'Main site', 'Client site') and their variants (i.e. 'Production' or 'QA').</p>
     57
     58<table class="form-table">
     59    <tr valign="top">
     60        <th scope="row">Site</th>
     61        <td>
     62            <input type="text" name="metrics_site" value="<?php echo get_option('metrics_site'); ?>" />
     63        </td>
     64    </tr>
     65    <tr>
     66        <th scope="row">Variant</th>
     67        <td>
     68            <input type="text" name="metrics_variant" value="<?php echo get_option('metrics_variant'); ?>" />
     69        </td>
     70  </tr>
     71</table>
     72
     73
    5474<h3>URIs to check</h3>
    5575
     
    7797    update_option('metrics_auth_username', sanitize_text_field($_REQUEST['metrics_auth_username']));
    7898    update_option('metrics_auth_password', sanitize_text_field($_REQUEST['metrics_auth_password']));
     99    update_option('metrics_site', sanitize_text_field($_REQUEST['metrics_site']));
     100    update_option('metrics_variant', sanitize_text_field($_REQUEST['metrics_variant']));
    79101    update_option('metrics_uris_to_check', sanitize_textarea_field($_REQUEST['metrics_uris_to_check']));
    80102
     
    93115    if(!get_option('metrics_auth_password')) {
    94116        update_option('metrics_auth_password', '');
     117    }
     118    if(!get_option('metrics_auth_site')) {
     119        update_option('metrics_auth_site', '');
     120    }
     121    if(!get_option('metrics_auth_variant')) {
     122        update_option('metrics_auth_variant', '');
    95123    }
    96124    if(!get_option('metrics_uris_to_check')) {
  • web-request-metrics/trunk/web-request-metrics.php

    r2175931 r2187003  
    55Plugin URI: https://wordpress.org/plugins/web-request-metrics
    66Description: Plugin to measure the HTTP connection metrics for key pages on your site
    7 Version: 0.2.4
     7Version: 0.3.0
    88Author: Ross Golder <ross@golder.org>
    99Author URI: http://www.golder.org/
     
    4545add_action("parse_request", "metrics_request_parser");
    4646
    47 function metrics_output_metric($id, $uri, $desc, $type, $all_stats, $key) {
     47function metrics_output_metric($id, $uri, $desc, $type, $all_stats, $key, $tags) {
    4848  echo "# HELP ".$id." ".$desc."\n";
    4949  echo "# TYPE ".$id." ".$type."\n";
     
    5454      $value = intval($value * 1000);
    5555    }
    56     echo $id."{uri=\"".$uri."\"} ".$value."\n";
     56    $tagstrs = array();
     57    foreach($tags as $tagkey => $tagvalue) {
     58      if($tagkey != "" && $tagvalue != "") {
     59        array_push($tagstrs, $tagkey."=\"".$tagvalue."\"");
     60      }
     61    }
     62    array_push($tagstrs, "uri=\"".$uri."\"");
     63    echo $id."{".join(", ",$tagstrs)."} ".$value."\n";
    5764  }
    5865
     
    94101  }
    95102
     103  $site =
     104  $variant = get_option("metrics_variant");
     105
    96106  header("Content-Type: text/plain");
    97107  header('Cache-Control: no-cache');
    98108
     109  $tags = array(
     110    'site' => get_option("metrics_site"),
     111    'variant' => get_option("metrics_variant")
     112  );
    99113  metrics_output_metric("web_request_header_size", $uri,
    100114    "The number of bytes in the HTTP header.",
    101115    "gauge",
    102     $stats, 'header_size'
     116    $stats, 'header_size', $tags
    103117  );
    104118
     
    106120    "The number of milliseconds taken in the hostname lookup.",
    107121    "gauge",
    108     $stats, 'namelookup_time'
     122    $stats, 'namelookup_time', $tags
    109123  );
    110124
     
    112126    "The number of milliseconds taken in the TCP connection.",
    113127    "gauge",
    114     $stats, 'connect_time'
     128    $stats, 'connect_time', $tags
    115129  );
    116130
     
    118132    "The number of milliseconds taken in the pretransfer stage.",
    119133    "gauge",
    120     $stats, 'pretransfer_time'
     134    $stats, 'pretransfer_time', $tags
    121135  );
    122136
     
    124138    "The number of milliseconds taken in the start transfer stage.",
    125139    "gauge",
    126     $stats, 'starttransfer_time'
     140    $stats, 'starttransfer_time', $tags
    127141  );
    128142
     
    130144    "The number of milliseconds taken in total.",
    131145    "gauge",
    132     $stats, 'total_time'
     146    $stats, 'total_time', $tags
    133147  );
     148
     149  exit(0);
    134150}
Note: See TracChangeset for help on using the changeset viewer.