Skip to content

Commit

Permalink
Remove timers at TM stop time
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Sep 13, 2023
1 parent 1955560 commit a646ed5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions jpos/src/main/java/org/jpos/transaction/TransactionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
}

0 comments on commit a646ed5

Please sign in to comment.