Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py

Issue 2103073002: Make Buildbot masters send ts_mon metrics, and add standard HTTP server metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@buildbot-tsmon
Patch Set: Oops Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/master/monitoring_status_receiver.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py
diff --git a/third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py b/third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py
index bf80065bc350c0780004d6830103eb5b036accb6..6c8db66e428774869b0fd3010b9371ab0998d84f 100644
--- a/third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py
+++ b/third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py
@@ -14,7 +14,7 @@
# Copyright Buildbot Team Members
-import os, weakref
+import os, time, weakref
from zope.interface import implements
from twisted.python import log
@@ -43,6 +43,8 @@ from buildbot.status.web.auth import AuthFailResource
from buildbot.status.web.root import RootPage
from buildbot.status.web.change_hook import ChangeHookResource
+from infra_libs.ts_mon.common import http_metrics
+
# this class contains the WebStatus class. Basic utilities are in base.py,
# and specific pages are each in their own module.
@@ -386,8 +388,36 @@ class WebStatus(service.MultiService):
maxRotatedFiles = either(self.maxRotatedFiles, self.master.log_rotation.maxRotatedFiles)
if not self.site:
-
+
+ class MonitoredRequest(server.Request):
+ def __init__(self, *args, **kwargs):
+ server.Request.__init__(self, *args, **kwargs)
+ self.startTime = time.time()
+
+ def render(self, resrc):
+ self.resourceClassName = resrc.__class__.__name__
+ server.Request.render(self, resrc)
+
class RotateLogSite(server.Site):
+ requestFactory = MonitoredRequest
+
+ def log(self, request):
+ server.Site.log(self, request)
+
+ durationMsec = 1000 * (time.time() - request.startTime)
+
+ requestLength = request.getHeader('content-length')
+ if requestLength is not None:
+ requestLength = int(requestLength)
+
+ http_metrics.update_http_server_metrics(
+ request.resourceClassName,
+ request.code,
+ durationMsec,
+ requestLength,
+ request.sentLength,
+ request.getHeader('user-agent') or '')
+
def _openLogFile(self, path):
try:
from twisted.python.logfile import LogFile
« no previous file with comments | « scripts/master/monitoring_status_receiver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698