4.51.2
All checks were successful
Build-Release-Image / Build-Image (linux/arm64) (push) Successful in 3m33s
Build-Release-Image / Build-Image (linux/amd64) (push) Successful in 3m35s
Build-Release-Image / Merge-Images (push) Successful in 25s
Build-Release-Image / Create-Release (push) Successful in 10s
Build-Release-Image / Notify (push) Successful in 3s
All checks were successful
Build-Release-Image / Build-Image (linux/arm64) (push) Successful in 3m33s
Build-Release-Image / Build-Image (linux/amd64) (push) Successful in 3m35s
Build-Release-Image / Merge-Images (push) Successful in 25s
Build-Release-Image / Create-Release (push) Successful in 10s
Build-Release-Image / Notify (push) Successful in 3s
This commit is contained in:
parent
556fae02d5
commit
d666f5af3f
@ -72,7 +72,9 @@ class PostgresEventSource(EventSource):
|
||||
Session.close() # Ensure we get a new connection and we don't leave a dangling tx
|
||||
|
||||
def __connect(self):
|
||||
self.__connection = psycopg2.connect(self.__connection_string)
|
||||
self.__connection = psycopg2.connect(
|
||||
self.__connection_string, application_name="sl-event-listen"
|
||||
)
|
||||
|
||||
from app.db import Session
|
||||
|
||||
|
@ -94,6 +94,20 @@ def log_nb_db_connection():
|
||||
newrelic.agent.record_custom_metric("Custom/nb_db_connections", nb_connection)
|
||||
|
||||
|
||||
@newrelic.agent.background_task()
|
||||
def log_nb_db_connection_by_app_name():
|
||||
# get the number of connections to the DB
|
||||
rows = Session.execute(
|
||||
"SELECT application_name, count(datid) FROM pg_stat_activity group by application_name"
|
||||
)
|
||||
for row in rows:
|
||||
if row[0].find("sl-") == 0:
|
||||
LOG.d("number of db connections for app %s = %s", row[0], row[1])
|
||||
newrelic.agent.record_custom_metric(
|
||||
f"Custom/nb_db_app_connection/{row[0]}", row[1]
|
||||
)
|
||||
|
||||
|
||||
@newrelic.agent.background_task()
|
||||
def log_pending_to_process_events():
|
||||
r = Session.execute("select count(*) from sync_event WHERE taken_time IS NULL;")
|
||||
@ -148,6 +162,7 @@ if __name__ == "__main__":
|
||||
log_pending_to_process_events()
|
||||
log_events_pending_dead_letter()
|
||||
log_failed_events()
|
||||
log_nb_db_connection_by_app_name()
|
||||
Session.close()
|
||||
|
||||
exporter.run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user