Ori.livneh has uploaded a new change for review.

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

Change subject: Add VisualEditor timing data reporter
......................................................................

Add VisualEditor timing data reporter

This is a copy-paste job, based on navtiming.py. This sort of barefaced code
duplication is something I try to avoid, so I tried extending EventLogging's
plugin architecture to cover the use-case of simple metric reporting modules in
Id8596535c. But I'm not convinced I got the design right, so I am reluctant to
merge that change. So instead, this.

Change-Id: I5838ff77458eff4080e5bcff526ead410b6795d5
---
M manifests/role/webperf.pp
A modules/webperf/files/ve.py
A modules/webperf/manifests/ve.pp
A modules/webperf/templates/ve.conf.erb
4 files changed, 108 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/48/109848/1

diff --git a/manifests/role/webperf.pp b/manifests/role/webperf.pp
index 38543f4..607f296 100644
--- a/manifests/role/webperf.pp
+++ b/manifests/role/webperf.pp
@@ -14,6 +14,13 @@
         statsd_host => $statsd_host,
     }
 
+    # Report VisualEditor performance measurements to Graphite.
+    # See <https://meta.wikimedia.org/wiki/Schema:TimingData>
+    class { '::webperf::ve':
+        endpoint    => 'tcp://vanadium.eqiad.wmnet:8600',
+        statsd_host => $statsd_host,
+    }
+
     # Provisions a service which gather stats about static assets count
     # and size using a headless browser instance. Stats are forwarded to
     # Ganglia using gmetric.
diff --git a/modules/webperf/files/ve.py b/modules/webperf/files/ve.py
new file mode 100644
index 0000000..66fefeb
--- /dev/null
+++ b/modules/webperf/files/ve.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+import sys
+reload(sys)
+sys.setdefaultencoding("utf-8")
+
+import argparse
+import logging
+import socket
+
+import zmq
+
+
+ap = argparse.ArgumentParser(description='PerfData StatsD module')
+ap.add_argument('endpoint', help='URI of EventLogging endpoint')
+ap.add_argument('--statsd-host', default='localhost',
+                type=socket.gethostbyname)
+ap.add_argument('--statsd-port', default=8125, type=int)
+args = ap.parse_args()
+
+ctx = zmq.Context()
+zsock = ctx.socket(zmq.SUB)
+zsock.hwm = 3000
+zsock.linger = 0
+zsock.connect(args.endpoint)
+zsock.subscribe = b''
+
+addr = args.statsd_host, args.statsd_port
+sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+
+for meta in iter(zsock.recv_json, ''):
+    if meta['revision'] == 7254808:
+        for point in meta['event']['points'].split(','):
+            stat = point.replace('=', ':') + '|ms'
+            sock.sendto(stat.encode('utf-8'), addr)
diff --git a/modules/webperf/manifests/ve.pp b/modules/webperf/manifests/ve.pp
new file mode 100644
index 0000000..2d5f555
--- /dev/null
+++ b/modules/webperf/manifests/ve.pp
@@ -0,0 +1,41 @@
+# == Class: webperf::ve
+#
+# Captures VisualEditor timing data and sends it to StatsD.
+#
+# === Parameters
+#
+# [*endpoint*]
+#   URI of EventLogging event publisher to subscribe to.
+#   Example: 'tcp://eventlogging.corp.org:8600'.
+#
+# [*statsd_host*]
+#   Write stats to this StatsD instance. Default: '127.0.0.1'.
+#
+# [*statsd_port*]
+#   Write stats to this StatsD instance. Default: 8125.
+#
+class webperf::ve(
+    $endpoint,
+    $statsd_host = '127.0.0.1',
+    $statsd_port = 8125,
+) {
+    include ::webperf
+
+    file { '/srv/webperf/ve.py':
+        source => 'puppet:///modules/webperf/ve.py',
+        owner  => 'www-data',
+        group  => 'www-data',
+        mode   => '0755',
+        notify => Service['ve'],
+    }
+
+    file { '/etc/init/ve.conf':
+        content => template('webperf/ve.conf.erb'),
+        notify  => Service['ve'],
+    }
+
+    service { 've':
+        ensure   => running,
+        provider => upstart,
+    }
+}
diff --git a/modules/webperf/templates/ve.conf.erb 
b/modules/webperf/templates/ve.conf.erb
new file mode 100644
index 0000000..3c204ed
--- /dev/null
+++ b/modules/webperf/templates/ve.conf.erb
@@ -0,0 +1,24 @@
+# navtiming
+#
+# This is an Upstart job configuration file for a Graphite metric module for
+# NavigationTiming events. For more information, see:
+# https://meta.wikimedia.org/wiki/Schema:NavigationTiming
+# http://www.mediawiki.org/wiki/Extension:NavigationTiming
+#
+# This file is managed by Puppet.
+#
+description "VisualEditor Graphite module"
+
+start on (local-filesystems and net-device-up IFACE!=lo)
+
+setuid webperf
+setgid webperf
+
+respawn
+respawn limit 15 5
+
+chdir /srv/webperf
+exec /usr/bin/python /srv/webperf/ve.py \
+    <%= @endpoint %> \
+    --statsd-host <%= @statsd_host %> \
+    --statsd-port <%= @statsd_port %>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5838ff77458eff4080e5bcff526ead410b6795d5
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