mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Merge pull request #3344 from Half-Shot/hs/as-metrics
Add metrics to track appservice transactions
This commit is contained in:
commit
13d211edc1
@ -24,8 +24,27 @@ from synapse.types import ThirdPartyInstanceID
|
|||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
from prometheus_client import Counter
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
sent_transactions_counter = Counter(
|
||||||
|
"synapse_appservice_api_sent_transactions",
|
||||||
|
"Number of /transactions/ requests sent",
|
||||||
|
["service"]
|
||||||
|
)
|
||||||
|
|
||||||
|
failed_transactions_counter = Counter(
|
||||||
|
"synapse_appservice_api_failed_transactions",
|
||||||
|
"Number of /transactions/ requests that failed to send",
|
||||||
|
["service"]
|
||||||
|
)
|
||||||
|
|
||||||
|
sent_events_counter = Counter(
|
||||||
|
"synapse_appservice_api_sent_events",
|
||||||
|
"Number of events sent to the AS",
|
||||||
|
["service"]
|
||||||
|
)
|
||||||
|
|
||||||
HOUR_IN_MS = 60 * 60 * 1000
|
HOUR_IN_MS = 60 * 60 * 1000
|
||||||
|
|
||||||
@ -219,12 +238,15 @@ class ApplicationServiceApi(SimpleHttpClient):
|
|||||||
args={
|
args={
|
||||||
"access_token": service.hs_token
|
"access_token": service.hs_token
|
||||||
})
|
})
|
||||||
|
sent_transactions_counter.labels(service.id).inc()
|
||||||
|
sent_events_counter.labels(service.id).inc(len(events))
|
||||||
defer.returnValue(True)
|
defer.returnValue(True)
|
||||||
return
|
return
|
||||||
except CodeMessageException as e:
|
except CodeMessageException as e:
|
||||||
logger.warning("push_bulk to %s received %s", uri, e.code)
|
logger.warning("push_bulk to %s received %s", uri, e.code)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.warning("push_bulk to %s threw exception %s", uri, ex)
|
logger.warning("push_bulk to %s threw exception %s", uri, ex)
|
||||||
|
failed_transactions_counter.labels(service.id).inc()
|
||||||
defer.returnValue(False)
|
defer.returnValue(False)
|
||||||
|
|
||||||
def _serialize(self, events):
|
def _serialize(self, events):
|
||||||
|
Loading…
Reference in New Issue
Block a user