Changeset 2187003
- Timestamp:
- 11/06/2019 01:59:48 PM (6 years ago)
- Location:
- web-request-metrics/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (2 diffs)
-
web-request-metrics-options.php (modified) (3 diffs)
-
web-request-metrics.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
web-request-metrics/trunk/readme.txt
r2175931 r2187003 5 5 * Requires at least: 4.7.2 6 6 * Tested up to: 5.3.0 7 * Stable tag: 0. 2.47 * Stable tag: 0.3.0 8 8 * License: GPLv2 9 9 … … 35 35 == Changelog == 36 36 37 = 0.3.0 = 38 39 * Add 'site' and 'variant' metrics tags. 40 37 41 = 0.2.4 = 38 42 -
web-request-metrics/trunk/web-request-metrics-options.php
r1967574 r2187003 52 52 </table> 53 53 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 54 74 <h3>URIs to check</h3> 55 75 … … 77 97 update_option('metrics_auth_username', sanitize_text_field($_REQUEST['metrics_auth_username'])); 78 98 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'])); 79 101 update_option('metrics_uris_to_check', sanitize_textarea_field($_REQUEST['metrics_uris_to_check'])); 80 102 … … 93 115 if(!get_option('metrics_auth_password')) { 94 116 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', ''); 95 123 } 96 124 if(!get_option('metrics_uris_to_check')) { -
web-request-metrics/trunk/web-request-metrics.php
r2175931 r2187003 5 5 Plugin URI: https://wordpress.org/plugins/web-request-metrics 6 6 Description: Plugin to measure the HTTP connection metrics for key pages on your site 7 Version: 0. 2.47 Version: 0.3.0 8 8 Author: Ross Golder <ross@golder.org> 9 9 Author URI: http://www.golder.org/ … … 45 45 add_action("parse_request", "metrics_request_parser"); 46 46 47 function metrics_output_metric($id, $uri, $desc, $type, $all_stats, $key ) {47 function metrics_output_metric($id, $uri, $desc, $type, $all_stats, $key, $tags) { 48 48 echo "# HELP ".$id." ".$desc."\n"; 49 49 echo "# TYPE ".$id." ".$type."\n"; … … 54 54 $value = intval($value * 1000); 55 55 } 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"; 57 64 } 58 65 … … 94 101 } 95 102 103 $site = 104 $variant = get_option("metrics_variant"); 105 96 106 header("Content-Type: text/plain"); 97 107 header('Cache-Control: no-cache'); 98 108 109 $tags = array( 110 'site' => get_option("metrics_site"), 111 'variant' => get_option("metrics_variant") 112 ); 99 113 metrics_output_metric("web_request_header_size", $uri, 100 114 "The number of bytes in the HTTP header.", 101 115 "gauge", 102 $stats, 'header_size' 116 $stats, 'header_size', $tags 103 117 ); 104 118 … … 106 120 "The number of milliseconds taken in the hostname lookup.", 107 121 "gauge", 108 $stats, 'namelookup_time' 122 $stats, 'namelookup_time', $tags 109 123 ); 110 124 … … 112 126 "The number of milliseconds taken in the TCP connection.", 113 127 "gauge", 114 $stats, 'connect_time' 128 $stats, 'connect_time', $tags 115 129 ); 116 130 … … 118 132 "The number of milliseconds taken in the pretransfer stage.", 119 133 "gauge", 120 $stats, 'pretransfer_time' 134 $stats, 'pretransfer_time', $tags 121 135 ); 122 136 … … 124 138 "The number of milliseconds taken in the start transfer stage.", 125 139 "gauge", 126 $stats, 'starttransfer_time' 140 $stats, 'starttransfer_time', $tags 127 141 ); 128 142 … … 130 144 "The number of milliseconds taken in total.", 131 145 "gauge", 132 $stats, 'total_time' 146 $stats, 'total_time', $tags 133 147 ); 148 149 exit(0); 134 150 }
Note: See TracChangeset
for help on using the changeset viewer.