Skip to content

[BUG] get_random_attr() in examples foo library never returns key5 #4584

Description

@Anish701

Steps to reproduce

cd build
cmake --build . --target all

./examples/metrics_simple/metrics_ostream_example

What is the expected behavior?
The keys should be randomized between key1 through key5. If the program is run many times, key5 should statistically show up.

What is the actual behavior?
No matter how many times I run the example program, I never see key5.

Additional context
I was going through the examples and noticed this bug when running the metrics_ostream_example. I investigated the library and found that the get_random_attr method in examples/common/metrics_foo_library/foo_library.cc mods random_int() by labels.size() - 1 rather than just labels.size(). This means that the last key-val pair in labels (key5) will never be returned. The fix is to update the method to mod by labels.size() rather than labels.size() - 1

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions