Hi! gauge: makes sense to define gauges inside processElement(). > Although new gauges will replace old gauges with the same name in the same metrics group, it is highly NOT recommended to do so because metrics may not be reported properly.
But it is a little awkward if these variables are used in classes/functions > deeply nested in processElement(). Yes it is. But this is what all operators do currently. Most operators create their metrics in the open() method and pass them around in the processElement() method. Lian Jiang <jiangok2...@gmail.com> 于2021年11月23日周二 上午12:08写道: > Hi, > > I want to get metrics inside a processElement() function of a > processWindowFucntion class. Below is my understanding: > > *counter*: a counter variable defined inside processElement() will be > reset every time when processElement() is called > > *meter*: a meter variable defined inside processElement() will be reset > every time when processElement() is called > > *histogram*: a histogram variable defined inside processElement() will be > reset every time when processElement() is called > > *gauge*: makes sense to define gauges inside processElement(). > > Is my understanding correct? I tried to define the metrics outside > processElement() and pass these variables to processElement(). But it is a > little awkward if these variables are used in classes/functions deeply > nested in processElement(). Can I make these metrics variables available in > Flink Runtime context so that the nested classes/functions can access these > variables from the runtime context? Appreciate your guidance! > >