Ori.livneh has submitted this change and it was merged.

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


Segment Navigation Timing data by continent

To project the impact of rolling out cache PoPs in more places around the
world, we need to have continuously-updating performance metrics segmented by
geographic region. So add another Navigation Timing metric hierarchy based on
the continent, which we derive from the GeoIP country code.

Bug: T128709
Change-Id: If12b79622645e1d09ceeb492a683b33eef4420c0
---
M modules/webperf/files/navtiming.py
1 file changed, 52 insertions(+), 3 deletions(-)

Approvals:
  Ori.livneh: Verified; Looks good to me, approved



diff --git a/modules/webperf/files/navtiming.py 
b/modules/webperf/files/navtiming.py
index ce5798c..24800c9 100755
--- a/modules/webperf/files/navtiming.py
+++ b/modules/webperf/files/navtiming.py
@@ -17,6 +17,53 @@
 
 handlers = {}
 
+# Mapping of continent names to ISO 3166 country codes.
+# From https://dev.maxmind.com/geoip/legacy/codes/country_continent/.
+# Antarctica excluded on account of its miniscule population.
+iso_3166_continent = {
+    'Africa': [
+        'AO', 'BF', 'BI', 'BJ', 'BW', 'CD', 'CF', 'CG', 'CI', 'CM', 'CV', 'DJ',
+        'DZ', 'EG', 'EH', 'ER', 'ET', 'GA', 'GH', 'GM', 'GN', 'GQ', 'GW', 'KE',
+        'KM', 'LR', 'LS', 'LY', 'MA', 'MG', 'ML', 'MR', 'MU', 'MW', 'MZ', 'NA',
+        'NE', 'NG', 'RE', 'RW', 'SC', 'SD', 'SH', 'SL', 'SN', 'SO', 'ST', 'SZ',
+        'TD', 'TG', 'TN', 'TZ', 'UG', 'YT', 'ZA', 'ZM', 'ZW'
+    ],
+    'Asia': [
+        'AE', 'AF', 'AM', 'AP', 'AZ', 'BD', 'BH', 'BN', 'BT', 'CC', 'CN', 'CX',
+        'CY', 'GE', 'HK', 'ID', 'IL', 'IN', 'IO', 'IQ', 'IR', 'JO', 'JP', 'KG',
+        'KH', 'KP', 'KR', 'KW', 'KZ', 'LA', 'LB', 'LK', 'MM', 'MN', 'MO', 'MV',
+        'MY', 'NP', 'OM', 'PH', 'PK', 'PS', 'QA', 'SA', 'SG', 'SY', 'TH', 'TJ',
+        'TL', 'TM', 'TW', 'UZ', 'VN', 'YE'
+    ],
+    'Europe': [
+        'AD', 'AL', 'AT', 'AX', 'BA', 'BE', 'BG', 'BY', 'CH', 'CZ', 'DE', 'DK',
+        'EE', 'ES', 'EU', 'FI', 'FO', 'FR', 'FX', 'GB', 'GG', 'GI', 'GR', 'HR',
+        'HU', 'IE', 'IM', 'IS', 'IT', 'JE', 'LI', 'LT', 'LU', 'LV', 'MC', 'MD',
+        'ME', 'MK', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'RS', 'RU', 'SE', 'SI',
+        'SJ', 'SK', 'SM', 'TR', 'UA', 'VA'
+    ],
+    'North_America': [
+        'AG', 'AI', 'AN', 'AW', 'BB', 'BL', 'BM', 'BS', 'BZ', 'CA', 'CR', 'CU',
+        'DM', 'DO', 'GD', 'GL', 'GP', 'GT', 'HN', 'HT', 'JM', 'KN', 'KY', 'LC',
+        'MF', 'MQ', 'MS', 'MX', 'NI', 'PA', 'PM', 'PR', 'SV', 'TC', 'TT', 'US',
+        'VC', 'VG', 'VI'
+    ],
+    'Oceania': [
+        'AS', 'AU', 'CK', 'FJ', 'FM', 'GU', 'KI', 'MH', 'MP', 'NC', 'NF', 'NR',
+        'NU', 'NZ', 'PF', 'PG', 'PN', 'PW', 'SB', 'TK', 'TO', 'TV', 'UM', 'VU',
+        'WF', 'WS'
+    ],
+    'South_America': [
+        'AR', 'BO', 'BR', 'CL', 'CO', 'EC', 'FK', 'GF', 'GY', 'PE', 'PY', 'SR',
+        'UY', 'VE'
+    ]
+}
+
+iso_3166_countries = {}
+for continent, countries in iso_3166_continent.items():
+    for country in countries:
+        iso_3166_countries[country] = continent
+
 
 def parse_ua(ua):
     """Return a tuple of browser_family and browser_major, or None.
@@ -192,9 +239,7 @@
         site = 'desktop'
     auth = 'anonymous' if event.get('isAnon') else 'authenticated'
 
-    # Currently unused:
-    # bits_cache = meta.get('recvFrom', '').split('.')[0]
-    # wiki = meta.get('wiki', '')
+    continent = iso_3166_countries.get(event.get('originCountry'))
 
     if 'sslNegotiation' in metrics:
         metrics = {'sslNegotiation': metrics['sslNegotiation']}
@@ -215,6 +260,10 @@
         if is_sane_experimental(value):
             dispatch_stat(prefix_experimental, metric, 'overall', value)
 
+        if continent is not None:
+            dispatch_stat(prefix, metric, 'by_continent', continent, value)
+
+
 if __name__ == '__main__':
     ap = argparse.ArgumentParser(description='NavigationTiming subscriber')
     ap.add_argument('endpoint', help='URI of EventLogging endpoint')

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If12b79622645e1d09ceeb492a683b33eef4420c0
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to