Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123264
D1311.id4155.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D1311.id4155.diff
View Options
diff --git a/swh/storage/api/server.py b/swh/storage/api/server.py
--- a/swh/storage/api/server.py
+++ b/swh/storage/api/server.py
@@ -13,11 +13,26 @@
from swh.core.api import (SWHServerAPIApp, decode_request,
error_handler,
encode_data_server as encode_data)
+from swh.core.statsd import statsd
+
app = SWHServerAPIApp(__name__)
storage = None
+def timed(f):
+ """Time that function!
+
+ """
+ def time_and_count_function(*a, **kw):
+ statsd.increment('swh_storage_request_count',
+ tags={'endpoint': f.__name__})
+ with statsd.timed('swh_storage_request_duration_seconds',
+ tags={'endpoint': f.__name__}):
+ return f(*a, **kw)
+ return time_and_count_function
+
+
@app.errorhandler(Exception)
def my_error_handler(exception):
return error_handler(exception, encode_data)
@@ -67,6 +82,7 @@
return encode_data(get_storage().content_find(**decode_request(request)))
+@timed
@app.route('/content/add', methods=['POST'])
def content_add():
return encode_data(get_storage().content_add(**decode_request(request)))
diff --git a/swh/storage/storage.py b/swh/storage/storage.py
--- a/swh/storage/storage.py
+++ b/swh/storage/storage.py
@@ -25,6 +25,7 @@
from swh.objstorage import get_objstorage
from swh.objstorage.exc import ObjNotFoundError
+
# Max block size of contents to return
BULK_BLOCK_CONTENT_LEN_MAX = 10000
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 8:29 AM (18 h, 39 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3214446
Attached To
D1311: storage: Add a timed decorator to count calls and time it
Event Timeline
Log In to Comment