Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce data sink to collect snapshot from each metric periodically #1117

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

empiredan
Copy link
Contributor

This PR is for #1116.

This PR introduces data sink to collect snapshot from each metric periodically. The base data sink is actually an abstract class that has interfaces needed by concrete monitoring systems. The unit test has implemented a data sink and verified if the snapshots can be received correctly.

@github-actions github-actions bot added the cpp label Aug 15, 2022
class metric_entity : public ref_counter
{
public:
using attr_map = std::unordered_map<std::string, std::string>;
using attr_map = std::map<std::string, std::string>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change to use std:map?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the attributes of an entity will be used as the labels of the metric. The labels will later be passed to metric_snapshot, thus each metric snapshot may has multiple labels. To maintain each snapshot in a map, data sink may choose to encode the labels a snapshot has, as what metric_snapshot::encode_attributes has done. In comparison with std::unordered_map, it is easier for std::map to be encoded since it's ordered.

@@ -215,6 +221,54 @@ class metric_entity_prototype
DISALLOW_COPY_AND_ASSIGN(metric_entity_prototype);
};

// `metric_timer` is a timer class that runs metric-related computations periodically, such as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runs metric-related computations periodically

Even though there isn't any thirdparty monitoring system, it will still caculate periodically? Would it be a bit of cost?
Another way is to calculate lazily, that is to say, calculate will only be triggered when any body request these metrics, you can define some callbacks for that.

ZhongChaoqiang pushed a commit to ZhongChaoqiang/incubator-pegasus that referenced this pull request Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants