Search in sources :

Example 6 with Stopwatch

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;
}
Also used : Stopwatch(com.uber.m3.tally.Stopwatch) Scope(com.uber.m3.tally.Scope) Timer(com.uber.m3.tally.Timer) CapableOf(com.uber.m3.tally.CapableOf) Map(java.util.Map) Counter(com.uber.m3.tally.Counter) Histogram(com.uber.m3.tally.Histogram) Capabilities(com.uber.m3.tally.Capabilities) Gauge(com.uber.m3.tally.Gauge) Duration(com.uber.m3.util.Duration) Buckets(com.uber.m3.tally.Buckets) Histogram(com.uber.m3.tally.Histogram) Timer(com.uber.m3.tally.Timer) Stopwatch(com.uber.m3.tally.Stopwatch) Duration(com.uber.m3.util.Duration)

Example 7 with Stopwatch

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;
}
Also used : Stopwatch(com.uber.m3.tally.Stopwatch)

Example 8 with Stopwatch

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));
}
Also used : Histogram(com.uber.m3.tally.Histogram) Scope(com.uber.m3.tally.Scope) Timer(com.uber.m3.tally.Timer) Stopwatch(com.uber.m3.tally.Stopwatch) Test(org.junit.Test)

Aggregations

Stopwatch (com.uber.m3.tally.Stopwatch)8 Scope (com.uber.m3.tally.Scope)5 Histogram (com.uber.m3.tally.Histogram)3 Timer (com.uber.m3.tally.Timer)3 TException (org.apache.thrift.TException)3 InternalServiceError (com.uber.cadence.InternalServiceError)2 ServiceBusyError (com.uber.cadence.ServiceBusyError)2 TaskList (com.uber.cadence.TaskList)2 Buckets (com.uber.m3.tally.Buckets)2 Test (org.junit.Test)2 BadRequestError (com.uber.cadence.BadRequestError)1 DomainAlreadyExistsError (com.uber.cadence.DomainAlreadyExistsError)1 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 PollForActivityTaskRequest (com.uber.cadence.PollForActivityTaskRequest)1 PollForActivityTaskResponse (com.uber.cadence.PollForActivityTaskResponse)1 PollForDecisionTaskRequest (com.uber.cadence.PollForDecisionTaskRequest)1 PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)1 QueryFailedError (com.uber.cadence.QueryFailedError)1 TaskListMetadata (com.uber.cadence.TaskListMetadata)1 WorkflowExecutionAlreadyCompletedError (com.uber.cadence.WorkflowExecutionAlreadyCompletedError)1