Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 34949ea

Browse files
author
David Robertson
authored
Track DB txn times w/ two counters, not histogram (#13342)
1 parent 5012275 commit 34949ea

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

changelog.d/13342.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When reporting metrics is enabled, use ~8x less data to describe DB transaction metrics.

synapse/storage/database.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040

4141
import attr
42-
from prometheus_client import Histogram
42+
from prometheus_client import Counter, Histogram
4343
from typing_extensions import Concatenate, Literal, ParamSpec
4444

4545
from twisted.enterprise import adbapi
@@ -76,7 +76,8 @@
7676
sql_scheduling_timer = Histogram("synapse_storage_schedule_time", "sec")
7777

7878
sql_query_timer = Histogram("synapse_storage_query_time", "sec", ["verb"])
79-
sql_txn_timer = Histogram("synapse_storage_transaction_time", "sec", ["desc"])
79+
sql_txn_count = Counter("synapse_storage_transaction_time_count", "sec", ["desc"])
80+
sql_txn_duration = Counter("synapse_storage_transaction_time_sum", "sec", ["desc"])
8081

8182

8283
# Unique indexes which have been added in background updates. Maps from table name
@@ -795,7 +796,8 @@ def new_transaction(
795796

796797
self._current_txn_total_time += duration
797798
self._txn_perf_counters.update(desc, duration)
798-
sql_txn_timer.labels(desc).observe(duration)
799+
sql_txn_count.labels(desc).inc(1)
800+
sql_txn_duration.labels(desc).inc(duration)
799801

800802
async def runInteraction(
801803
self,

0 commit comments

Comments
 (0)