Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/81464


Change subject: Change metric name format for NavigationTiming events
......................................................................

Change metric name format for NavigationTiming events

This patch changes the name format of NavigationTiming metrics logged to
Graphite to better match how we analyze the data. The change allows us to
include data from all countries, not just the top 10.

Change-Id: I93403c81a71d3935f5e6fce93eee9f21d86fe3bb
---
M files/graphite/modules/navtiming.py
1 file changed, 12 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/64/81464/1

diff --git a/files/graphite/modules/navtiming.py 
b/files/graphite/modules/navtiming.py
index 8b4f391..987ad98 100644
--- a/files/graphite/modules/navtiming.py
+++ b/files/graphite/modules/navtiming.py
@@ -14,7 +14,6 @@
 schema_rev = 5336845
 metrics = ('connecting', 'sending', 'waiting', 'redirecting', 'receiving',
            'rendering', 'loading')
-countries = ('US', 'GB', 'JP', 'DE', 'RU', 'BR', 'CA', 'FR', 'IN')
 
 
 ap = argparse.ArgumentParser(description='NavigationTiming Graphite module')
@@ -34,24 +33,19 @@
 
 addr = args.statsd_host, args.statsd_port
 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-for meta_event in iter(zsock.recv_json, ''):
-    if meta_event['revision'] != schema_rev:
+
+for meta in iter(zsock.recv_json, ''):
+    if meta['revision'] != schema_rev:
         continue
-    event = meta_event['event']
+    event = meta['event']
     if not event.get('isAnon'):
         continue
-    if 'mobileMode' in event:
-        site = 'mobile.' + event['mobileMode']
-    else:
-        site = 'desktop'
-    metric_strings = [site]
-    if event.get('originCountry') in countries:
-        metric_strings.append('%s.%s' % (event['originCountry'], site))
+
+    site = 'mobile' if 'mobileMode' in event else 'desktop'
+    country = event.get('originCountry') or 'ZZ'
+
     for metric in metrics:
-        if event.get(metric) < 0:
-            continue
-        for metric_string in metric_strings:
-            stat = ('navigation_timing.%s.%s:%s|ms' %
-                    (metric_string, metric, event[metric]))
-            stat = stat.encode('utf-8')
-            sock.sendto(stat, addr)
+        value = event.get(metric)
+        if value > 0:
+            stat = 'navigation.%s.%s.%s:%s|ms' % (metric, site, country, value)
+            sock.sendto(stat.encode('utf-8'), addr)

-- 
To view, visit https://gerrit.wikimedia.org/r/81464
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I93403c81a71d3935f5e6fce93eee9f21d86fe3bb
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to