How to access the Metric Data which is getting generated using java SDK

Experts,

How can we access the temporal data which is generating the Metrics. I am trying to access the Metric using Java SDK by using this link How to enable Metrics Support using JAVA SDK

TIA

1 Like

You need to do something like this:

    new WorkflowServiceStubsImpl(null, WorkflowServiceStubsOptions
                    .newBuilder()
                    .setChannel(channel)
                    .setRpcTimeout(rpcTimeout)
                    .setQueryRpcTimeout(queryRpcTimeout)
                    **.setMetricsScope(StatsDMetricsScopeFactory.getStatsDMetricScope("PROD"))**
                    .build());

Inside the metric Scope you need to create a
import com.uber.m3.tally.StatsReporter so it can connect to your statsD or other metrics client

public static Scope getStatsDMetricScope(String environment) {
        StatsDClient statsDClient =
                new NonBlockingStatsDClient(
                        environment /* metrics prefix */,
                        "127.0.0.1" /* statsD server hostname */,
                        8125 /* statsD port */);
        StatsReporter statsReporter = new StatsDReporter(statsDClient);
        return new RootScopeBuilder()
                .reporter(statsReporter)
                .reportEvery(Duration.ofSeconds(10));
    }
1 Like