use of com.uber.m3.tally.Stopwatch in project cadence-client by uber-java.
the class NoopScope method getInstance.
public static synchronized Scope getInstance() {
if (noopScope == null) {
noopCounter = delta -> {
};
noopGauge = value -> {
};
noopTimer = new Timer() {
@Override
public void record(Duration interval) {
}
@Override
public Stopwatch start() {
return new Stopwatch(0, stopwatchStart -> {
});
}
};
noopHistogram = new Histogram() {
@Override
public void recordValue(double value) {
}
@Override
public void recordDuration(Duration value) {
}
@Override
public Stopwatch start() {
return new Stopwatch(0, stopwatchStart -> {
});
}
};
noopScope = new NoopScope();
}
return noopScope;
}
use of com.uber.m3.tally.Stopwatch in project cadence-client by uber-java.
the class ReplayWorkflowActivityImpl method replayWorkflowHistory.
protected boolean replayWorkflowHistory(String domain, WorkflowExecution execution, WorkflowExecutionHistory workflowHistory) throws Exception {
Stopwatch sw = this.metricsScope.timer(MetricsType.REPLAY_LATENCY).start();
try {
worker.replayWorkflowExecution(workflowHistory);
} catch (Exception e) {
if (isNonDeterministicError(e)) {
log.error("failed to replay workflow history with domain: " + domain + ". Execution: " + execution.toString(), e);
throw e;
} else if (isWorkflowTypeNotRegisterError(e)) {
log.info("replay unregistered workflow execution: {}", execution.toString(), e);
throw new NonRetryableException(e);
} else {
log.info("replay workflow execution: {} skipped", execution.toString(), e);
return false;
}
} finally {
sw.stop();
}
log.info("replay workflow execution: {} succeed", execution.toString());
return true;
}
use of com.uber.m3.tally.Stopwatch in project sdk-java by temporalio.
the class ReplayAwareScopeTest method testCustomClockForTimer.
@Test
public void testCustomClockForTimer() {
Scope scope = mock(Scope.class);
Timer timer = mock(Timer.class);
Histogram histogram = mock(Histogram.class);
@SuppressWarnings("deprecation") com.uber.m3.tally.Buckets buckets = ValueBuckets.linear(0, 10, 10);
when(scope.timer("test-timer")).thenReturn(timer);
when(scope.histogram("test-histogram", buckets)).thenReturn(histogram);
TestContext context = new TestContext(false);
TestClock clock = new TestClock();
clock.setTime(0);
Scope replayAwareScope = new ReplayAwareScope(scope, context, clock);
Stopwatch sw = replayAwareScope.timer("test-timer").start();
clock.setTime(100);
sw.stop();
sw = replayAwareScope.histogram("test-histogram", buckets).start();
clock.setTime(150);
sw.stop();
verify(timer, times(1)).record(Duration.ofMillis(100));
verify(histogram, times(1)).recordDuration(Duration.ofMillis(50));
}
Aggregations