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

Adding Metrics family config #2121

Merged
merged 4 commits into from
Mar 20, 2024
Merged

Commits on Feb 26, 2024

  1. metrics_api.hh: Remove duplication of metric family metadata

    Metric family metadata consists of information relevant to all metrics
    with the same name (but with different labels).  For example, name,
    description, and aggregate labels.
    
    The metric family metadata is found in two data structures: the
    _value_map that holds all registered metrics and _metadata that contains
    only reported metrics.
    
    This patch makes the _metadata hold a reference to the data in the
    _value_map instead of copying it, which serves two purposes:
    1. Minor performance gain (memory and computation).
    2. It will now be possible for a change in _value_map to be reflected in
       _metadata.
    
    Signed-off-by: Amnon Heiman <[email protected]>
    amnonh committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    d2929c2 View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2024

  1. core/relabel_config.hh: support metric family config

    This patch adds support for metric family config.
    A metric family config is a configuration that relates to all the
    metrics with the same name (but with different labels).
    
    The configuration would allow changing the labels aggregation for
    metrics.
    
    Besides the configuration class, which is similar to
    metrics_relabel_config, two enhancements were added to the
    relabel_config_regex:
    
    1. empty() which check if it's empty or not.
    2. match() that checks if the regex is nonempty and matches a string
    without returning the matched group.
    
    Signed-off-by: Amnon Heiman <[email protected]>
    amnonh committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    352c8ce View commit details
    Browse the repository at this point in the history
  2. metrics: Adds metric_family_config support

    Family config is a configuration that relates to all metrics with the
    same name but with different labels values.
    
    set_metric_family_configs allows changing that configuration during run
    time. Specifically, change the label aggregation based on a metric name.
    
    The following is an example for setting the aggregate labels for the
    metric test_gauge_1 and all metrics matching the regex test_gauge1.*:
    
    std::vector<sm::metric_family_config> fc(2);
    fc[0].name = "test_gauge_1";
    fc[0].aggregate_labels = { "lb" };
    fc[1].regex_name = "test_gauge1.*";
    fc[1].aggregate_labels = { "ll", "aa" };
    
    sm::set_metric_family_configs(fc);
    
    Signed-off-by: Amnon Heiman <[email protected]>
    
    include/seastar/core/metrics_api.hh
    amnonh committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    9c148f3 View commit details
    Browse the repository at this point in the history
  3. tests/unit/metrics_test.cc: Test metrics family config

    This patch adds a test for the family config API. it register metrics
    and change their aggregate labels.
    It check that both metrics that create before and after the call to
    set_metric_family_configs works as expected.
    
    Signed-off-by: Amnon Heiman <[email protected]>
    amnonh committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    9a80dce View commit details
    Browse the repository at this point in the history