Madhuvishy has uploaded a new change for review.
https://gerrit.wikimedia.org/r/229631
Change subject: [WIP] Send mysql consumer stats to statsd
......................................................................
[WIP] Send mysql consumer stats to statsd
Bug: T105935
Change-Id: Ifc78750aefe19072c2ad613b417f48ebc7a87ab8
---
M server/eventlogging/handlers.py
1 file changed, 13 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging
refs/changes/31/229631/1
diff --git a/server/eventlogging/handlers.py b/server/eventlogging/handlers.py
index b75c532..c7699be 100644
--- a/server/eventlogging/handlers.py
+++ b/server/eventlogging/handlers.py
@@ -32,6 +32,7 @@
import socket
import sys
import sqlalchemy
+import statsd
import time
import traceback
import uuid
@@ -222,11 +223,19 @@
@writes('mysql', 'sqlite')
-def sql_writer(uri, replace=False):
+def sql_writer(uri, replace=False, statsd_host=''):
"""Writes to an RDBMS, creating tables for SCIDs and rows for events."""
- # Don't pass 'replace' parameter to SQLAlchemy.
+ # Don't pass 'replace' and 'statsd_host' parameter to SQLAlchemy.
uri = uri_delete_query_item(uri, 'replace')
+ uri = uri_delete_query_item(uri, 'statsd_host')
+
logger = logging.getLogger('Log')
+
+ # Create a statsd client instance if statsd_host is specified
+ stats = None
+ if statsd_host:
+ stats = statsd.StatsClient(statsd_host, 8125, prefix='eventlogging')
+
meta = sqlalchemy.MetaData(bind=uri)
# Each scid stores a buffer and the timestamp of the first insertion.
events = collections.defaultdict(lambda: ([], time.time()))
@@ -254,6 +263,8 @@
scid = (event['schema'], event['revision'])
scid_events, first_timestamp = events[scid]
scid_events.append(event)
+ if stats:
+ stats.incr('overall.insertAttempted')
# Check if the schema queue is too long or too old
if (len(scid_events) >= batch_size or
time.time() - first_timestamp >= batch_time):
--
To view, visit https://gerrit.wikimedia.org/r/229631
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc78750aefe19072c2ad613b417f48ebc7a87ab8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: Madhuvishy <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits