Closed ganmacs closed 4 years ago
Using filter
seems good approach but I think this implementation is not good for memory because instrument
creates placeholder value internally.
So to avoid such problem, light-weight instrument implementation is needed. From my view, implementing own expander is better: https://github.com/fluent/fluent-plugin-prometheus/blob/aaef57a777a3732438652d5320dcd29bfc04299a/lib/fluent/plugin/prometheus.rb#L86 Current implementation depends on record_transformer. This isn't robust because record_transformer's internal class may be changed.
Using filter seems good approach but I think this implementation is not good for memory because instrument creates placeholder value internally.
Sorry. I didn't get why it's not good for memory. placeholder_value
is a Hash object, right?
Is creating a this hash each record problem?
Current implementation depends on record_transformer. This isn't robust because record_transformer's internal class may be changed.
Right. but I think it should be done in another PR to minimize the change.
@repeatedly ping
Is creating a this hash each record problem?
I'm not sure the impact. Old implementation creates only 1 placholder hash per event steam: https://github.com/fluent/fluent-plugin-prometheus/blob/aaef57a777a3732438652d5320dcd29bfc04299a/lib/fluent/plugin/prometheus.rb#L96 But new implementation creates placeholder hash per record. So if event steam contains 1000 events, new implementation creates 1000 records even if tag is same.
Right. but I think it should be done in another PR to minimize the change.
Yeah, I think so.
cached placeholder_value
by tag for safety.
https://github.com/fluent/fluent-plugin-prometheus/pull/124/commits/f58e9427abb4e0d62654c7ec9eb56259f3318943
I created a dedicated method for handling signle record and reverted all changes about #instrument
@kazegusuri How about this patch? If you are ok, we want to release new version with this change.
It seems okay. Just a question and my curious. Is this simple for performance improvement?
Is this simple for performance improvement?
Yes. In addition, if record
is nil for some reasons, utilizing fluentd core's rescue logic.
Default implementation of Flunet::Filter#filter_stream has rescue statement by default. so if received record is invalid, it would work without any error. and It can be faster by using fileter optimization feature (https://docs.fluentd.org/filter#filter-chain-optimization)