Nihar Rao
02/06/2023, 10:37 PMpublic class FlinkMetric extends RichMapFunction<String, String> {
public void playWithMetrics() {
// Gauge
Gauge<Integer> random = () -> 1;
this.getRuntimeContext().getMetricGroup().gauge("myGauge", random);
}
@Override
public String map(String value) throws Exception {
return null;
}
}
This class is simply called my the main class and I am running my application as a jar by submitting it on flink web's submit job option. I am getting the following error:
java.lang.IllegalStateException: The runtime context has not been initialized yet.
I looked into it and I understand that the runtime context is null. Can you please tell me why the runtime context is not getting set automatically?
Thankssap1ens
02/06/2023, 10:39 PMopen method first as a metric, you only have access to the runtime context there.Nihar Rao
02/06/2023, 11:07 PMFlinkMetric().open(new Configuration())
I don't understand when is the lifecycle open() called? is it the right way?David Anderson
02/06/2023, 11:22 PMNihar Rao
02/07/2023, 1:29 AMDavid Anderson
02/07/2023, 1:34 AMNihar Rao
02/07/2023, 1:41 AMDavid Anderson
02/07/2023, 1:56 AMDavid Anderson
02/07/2023, 1:57 AMsap1ens
02/07/2023, 1:59 AMNihar Rao
02/07/2023, 5:30 PM