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

Track DB txn times w/ two counters, not histogram #13342

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13342.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When reporting metrics is enabled, use ~8x less data to describe DB transaction metrics.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this should be .feature?

8 changes: 5 additions & 3 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)

import attr
from prometheus_client import Histogram
from prometheus_client import Counter, Histogram
from typing_extensions import Concatenate, Literal, ParamSpec

from twisted.enterprise import adbapi
Expand Down Expand Up @@ -76,7 +76,8 @@
sql_scheduling_timer = Histogram("synapse_storage_schedule_time", "sec")

sql_query_timer = Histogram("synapse_storage_query_time", "sec", ["verb"])
sql_txn_timer = Histogram("synapse_storage_transaction_time", "sec", ["desc"])
sql_txn_count = Counter("synapse_storage_transaction_time_count", "sec", ["desc"])
sql_txn_duration = Counter("synapse_storage_transaction_time_sum", "sec", ["desc"])


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

self._current_txn_total_time += duration
self._txn_perf_counters.update(desc, duration)
sql_txn_timer.labels(desc).observe(duration)
sql_txn_count.labels(desc).inc(1)
sql_txn_duration.labels(desc).inc(duration)

async def runInteraction(
self,
Expand Down