Ori.livneh has uploaded a new change for review.

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

Change subject: Segment Navigation Timing data by country
......................................................................

Segment Navigation Timing data by country

Provide Navigation Timing metrics segmented by country for the top 30 most
populous countries in the world. Together these countries represent just under
80% of the world's total population.

Bug: T128709
Change-Id: I1d524cdb918afa59643cf2c20897a17ad1a755e7
---
M modules/webperf/files/navtiming.py
1 file changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/84/278684/1

diff --git a/modules/webperf/files/navtiming.py 
b/modules/webperf/files/navtiming.py
index 24800c9..80e31ac 100755
--- a/modules/webperf/files/navtiming.py
+++ b/modules/webperf/files/navtiming.py
@@ -64,6 +64,19 @@
     for country in countries:
         iso_3166_countries[country] = continent
 
+# Map of ISO 3166 => Country name for the world's top 30 most populous
+# countries as of 1 January 2016.
+iso_3166_top_30 = {
+    'BD': 'Bangladesh', 'BR': 'Brazil', 'CD': 'DR_Congo', 'CN': 'China',
+    'CO': 'Colombia', 'DE': 'Germany', 'EG': 'Egypt', 'ES': 'Spain',
+    'ET': 'Ethiopia', 'FR': 'France', 'GB': 'United_Kingdom',
+    'ID': 'Indonesia', 'IN': 'India', 'IR': 'Iran', 'IT': 'Italy',
+    'JP': 'Japan', 'KE': 'Kenya', 'KR': 'South_Korea', 'MM': 'Myanmar',
+    'MX': 'Mexico', 'NG': 'Nigeria', 'PH': 'Philippines', 'PK': 'Pakistan',
+    'RU': 'Russia', 'TH': 'Thailand', 'TR': 'Turkey', 'TZ': 'Tanzania',
+    'US': 'United_States', 'VN': 'Vietnam', 'ZA': 'South_Africa',
+}
+
 
 def parse_ua(ua):
     """Return a tuple of browser_family and browser_major, or None.
@@ -239,7 +252,9 @@
         site = 'desktop'
     auth = 'anonymous' if event.get('isAnon') else 'authenticated'
 
-    continent = iso_3166_countries.get(event.get('originCountry'))
+    country_code = event.get('originCountry')
+    continent = iso_3166_countries.get(country_code)
+    country_name = iso_3166_top_30.get(country_code)
 
     if 'sslNegotiation' in metrics:
         metrics = {'sslNegotiation': metrics['sslNegotiation']}
@@ -263,6 +278,9 @@
         if continent is not None:
             dispatch_stat(prefix, metric, 'by_continent', continent, value)
 
+        if country_name is not None:
+            dispatch_stat(prefix, metric, 'by_country', country_name, value)
+
 
 if __name__ == '__main__':
     ap = argparse.ArgumentParser(description='NavigationTiming subscriber')

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d524cdb918afa59643cf2c20897a17ad1a755e7
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to