Ori.livneh has uploaded a new change for review.

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


Change subject: Add txStatsD module
......................................................................

Add txStatsD module

txStatsD is Canonical's port of Etsy's StatsD to Python. We currently use
Etsy's StatsD, but I'd like to evaluate txStatsD as a replacement.

What I like about txStatsD is that it uses the Twisted framework to get all the
scaffolding of a polling network daemon, including a flexible command-line
runner and a simple plug-in architecture. We can use the plug-in architecture
to implement simple regex-based metric filters that let you specify which
summary statistics should be computed and to which backend they should be
routed. This is in contrast with Etsy's StatsD, which doesn't provide hooks for
this sort of thing.

txStatsD also provides a Python API for implementing metric-reporting clients.
There is the potential there for making our various metric modules
singificantly simpler and shorter. For an example client, see:
<https://github.com/sidnei/txstatsd/blob/master/example-stats-client.tac>

I plan to remove the statsd module if txStatsD proves to be a suitable
replacement.

Change-Id: I19ecf608d64a9ed13fbd3dfa41bd28b43f5a7bd1
---
A modules/txstatsd/files/txstatsd.conf
A modules/txstatsd/manifests/init.pp
A modules/txstatsd/templates/txstatsd.cfg.erb
3 files changed, 88 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/10/108010/1

diff --git a/modules/txstatsd/files/txstatsd.conf 
b/modules/txstatsd/files/txstatsd.conf
new file mode 100644
index 0000000..f0f43d4
--- /dev/null
+++ b/modules/txstatsd/files/txstatsd.conf
@@ -0,0 +1,15 @@
+# vim: set ft=upstart:
+# Upstart job definition for txStatsD
+description "txStatsD metrics aggregation network daemon"
+
+setuid txstatsd
+setgid txstatsd
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+respawn
+respawn limit 10 5
+
+exec twistd -n -l- --pidfile= statsd \
+    --config=/etc/txstatsd/txstatsd.cfg
diff --git a/modules/txstatsd/manifests/init.pp 
b/modules/txstatsd/manifests/init.pp
new file mode 100644
index 0000000..713d7b7
--- /dev/null
+++ b/modules/txstatsd/manifests/init.pp
@@ -0,0 +1,63 @@
+# == Class: txstatsd
+#
+# txStatsD is a network daemon that listens on a socket for metric data (like
+# timers and counters) and writes aggregates to a metric storage backend like
+# Graphite or Ganglia. See <https://github.com/sidnei/txstatsd>.
+#
+# === Parameters
+#
+# [*settings*]
+#   Hash of hashes. Each top-level hash correspond to a config section.
+#   See <https://github.com/sidnei/txstatsd/blob/master/txstatsd.conf-example>.
+#
+# === Examples
+#
+#  class { 'txstatsd':
+#    settings => {
+#      statsd => {
+#        'carbon-cache-host' => localhost,
+#        'carbon-cache-port' => 2003,
+#        'listen-tcp-port'   => 8125,
+#      },
+#    },
+#  }
+#
+class txstatsd($settings) {
+    package { 'python-txstatsd': }
+
+    file { '/etc/init/txstatsd.conf':
+        source => 'puppet:///modules/txstatsd/txstatsd.conf',
+    }
+
+    file { '/etc/txstatsd':
+        ensure => directory,
+    }
+
+    file { '/etc/txstatsd/txstatsd.cfg':
+        content => template('txstatsd/txstatsd.cfg.erb'),
+    }
+
+    group { 'txstatsd':
+        ensure => present,
+    }
+
+    user { 'txstatsd':
+        ensure     => present,
+        gid        => 'txstatsd',
+        shell      => '/bin/false',
+        home       => '/nonexistent',
+        system     => true,
+        managehome => false,
+    }
+
+    service { 'txstatsd':
+        ensure    => running,
+        provider  => upstart,
+        subscribe => File['/etc/txstatsd/txstatsd.cfg'],
+        require   => [
+            File['/etc/init/txstatsd.conf'],
+            Package['python-txstatsd'],
+            User['txstatsd'],
+        ],
+    }
+}
diff --git a/modules/txstatsd/templates/txstatsd.cfg.erb 
b/modules/txstatsd/templates/txstatsd.cfg.erb
new file mode 100644
index 0000000..8417a2b
--- /dev/null
+++ b/modules/txstatsd/templates/txstatsd.cfg.erb
@@ -0,0 +1,10 @@
+# Configuraton file for txStatsD
+# This file is managed by Puppet
+<%=
+    @settings.sort.map { |section,items|
+            ["[#{section}]"].concat items.sort.map { |k,v|
+                v = v.is_a?(Array) ? v.join(',') : (v == :undef ? '' : v)
+                "#{k} = #{v}"
+            }.push []
+    }.join("\n")
+%>

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

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