quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.88k stars 2.71k forks source link

Transaction API / micrometer integration #30791

Open pjgg opened 1 year ago

pjgg commented 1 year ago

Description

Hi, I was playing with transaction API quarkus-narayana-jta (that comes with quarkus-hibernate-orm-panache) and I would like to open a discussion about "default metrics".

Currently, there are several "default metrics" that comes with some extensions, for example related to postgres we could find the following ones:

# TYPE postgresql_reset counter
# HELP postgresql_reset Total number of resets
postgresql_reset_total{clientName="<default>",clientType="sql"} 0.0
# TYPE postgresql_queue_delay_seconds summary
# HELP postgresql_queue_delay_seconds Time spent in the waiting queue before being processed
postgresql_queue_delay_seconds_count{clientName="<default>",clientType="sql"} 1.0
postgresql_queue_delay_seconds_sum{clientName="<default>",clientType="sql"} 0.010889765
# TYPE postgresql_queue_delay_seconds_max gauge
# HELP postgresql_queue_delay_seconds_max Time spent in the waiting queue before being processed
postgresql_queue_delay_seconds_max{clientName="<default>",clientType="sql"} 0.010889765

I think that could be useful to add some metrics related to JTA transactions, for example, the total amount of rollbacks that are done, so the end user could define some alerts based on these metrics.

I am not sure about other transaction metrics...

WDYT?

quarkus-bot[bot] commented 1 year ago

/cc @ebullient (micrometer)

ebullient commented 1 year ago

We can add additional, but to the extent possible, I would prefer we create/work with the micrometer community if additional binders are interesting.

rsvoboda commented 1 year ago

/cc @mmusgrov @tomjenkinson

mmusgrov commented 1 year ago

We provide stats but they need to be enabled (https://github.com/jbosstm/narayana/blob/main/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java#L353):

number-of-aborted-transactions The number of aborted (i.e. rolled-back) transactions.
number-of-application-rollbacks The number of transactions that have been rolled back by application request. This includes those that timeout, since the timeout behavior is considered an attribute of the application configuration.
number-of-committed-transactions The number of committed transactions.
number-of-heuristics The number of transactions which have terminated with heuristic outcomes.
number-of-inflight-transactions The number of transactions that have begun but not yet terminated.
number-of-nested-transactions The total number of nested (sub) transactions created.
number-of-resource-rollbacks The number of transactions that rolled back due to resource (participant) failure.
number-of-system-rollbacks The number of transactions that have been rolled back due to internal system errors.
number-of-timed-out-transactions The number of transactions that have rolled back due to timeout.
number-of-transactions The total number of transactions (top-level and nested) created.