Metrics: FilteringAttributesProcessor has no effect #2468
Labels
bug
Something isn't working
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
Describe your environment
I am using Windows, and building with Visual Studio 2019
Steps to reproduce
This issue can be reproduced by making some small changes to the "metrics_simple" example. Replace the files examples/metrics_simple/metrics_ostream.cc and examples/common/metrics_foo_library/foo_library.cc with the attached version. The new files simply add a FilteringAttributesProcessor to the counter View, which should filter out one of the two attributes. Build the example and run.
What is the expected behavior?
I expect to see only the "Group" attribute in the output, as "Subgroup" attribute should have been dropped.
What is the actual behavior?
I see both "Group" and "Subgroup" attributes in the output, which is the same output if I have not included the FilteringAttributesProcessor.
Additional context
I looked into the code. The problem seems to be in sdk/metrics/state/sync_metric_storage.h, in functions RecordLong and RecordDouble. The attribute processor is only used when generating the hash, which seems insufficient. Later on, in the call to GetOrSetDefault, the unfiltered attributes are used. This seems to override any effect of the attribute processor.
foo_library.cc.txt
metrics_ostream.cc.txt
The text was updated successfully, but these errors were encountered: