From a646ed5b24273dfcb1203c789dcc081fdc6ebb81 Mon Sep 17 00:00:00 2001 From: Alejandro Revilla Date: Wed, 13 Sep 2023 17:30:52 -0300 Subject: [PATCH] Remove timers at TM stop time --- .../jpos/transaction/TransactionManager.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/jpos/src/main/java/org/jpos/transaction/TransactionManager.java b/jpos/src/main/java/org/jpos/transaction/TransactionManager.java index 9f742e7833..d9fbdce350 100644 --- a/jpos/src/main/java/org/jpos/transaction/TransactionManager.java +++ b/jpos/src/main/java/org/jpos/transaction/TransactionManager.java @@ -20,6 +20,7 @@ import io.micrometer.core.instrument.*; import io.micrometer.core.instrument.Tags; +import io.micrometer.core.instrument.Timer; import io.micrometer.core.instrument.binder.BaseUnits; import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.core.instrument.distribution.DistributionStatisticConfig; @@ -404,6 +405,8 @@ public void setConfiguration (Configuration cfg) throws ConfigurationException { transactionCounter = MeterFactory.counter (getServer().getMeterRegistry(), MeterInfo.TM_COUNTER, Tags.of("name", getName()) ); + meters.add(activeSessionsGauge); + meters.add(transactionCounter); } catch (Exception e) { throw new ConfigurationException (e); } @@ -1257,11 +1260,16 @@ private Timers getOrCreateTimers(TransactionParticipant p) { tags = tags.and("realm", realm.trim()); } return new Timers( - MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "prepare")), - MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "prepare-for-abort")), - MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "commit")), - MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "abort")), - MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "snapshot")) + addTimer(MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "prepare"))), + addTimer(MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "prepare-for-abort"))), + addTimer(MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "commit"))), + addTimer(MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "abort"))), + addTimer(MeterFactory.timer(mr, MeterInfo.TM_OPERATION, tags.and("phase", "snapshot"))) ); } + + private Timer addTimer (Timer m) { + meters.add (m); + return m; + } }