Skip to content

Commit

Permalink
Improved Timer Metric
Browse files Browse the repository at this point in the history
  • Loading branch information
switschel committed Oct 14, 2024
1 parent dd3badd commit a047c12
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public MappingOutboundTask(ConfigurationRegistry configurationRegistry, List<Map
@Override
public List<ProcessingContext<?>> call() throws Exception {
long startTime = System.nanoTime();

Timer.Sample timer = Timer.start(Metrics.globalRegistry);
String tenant = c8yMessage.getTenant();
boolean sendPayload = c8yMessage.isSendPayload();

Expand Down Expand Up @@ -276,12 +278,11 @@ public List<ProcessingContext<?>> call() throws Exception {
.description("Total number of outbound messages")
.tag("connector", processor.connectorClient.getConnectorIdent())
.register(Metrics.globalRegistry).increment();
Timer.builder("dynmapper_outbound_processing_time")
timer.stop(Timer.builder("dynmapper_outbound_processing_time")
.tag("tenant", c8yMessage.getTenant())
.tag("connector", processor.connectorClient.getConnectorIdent())
.description("Processing time of outbound messages")
.register(Metrics.globalRegistry)
.record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
.register(Metrics.globalRegistry));

List<C8YRequest> resultRequests = context.getRequests();
if (context.hasError() || resultRequests.stream().anyMatch(r -> r.hasError())) {
Expand Down

0 comments on commit a047c12

Please sign in to comment.