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

Sanitize metric type prefixes #319

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

Commits on Mar 19, 2024

  1. Sanitize metric type prefixes

    When more than one prefix matches the same metric descriptor, this will
    throw the error "collected metric xxx was collected before with the
    same name and label values".
    
    For example, using the metric type prefixes
      foo.googleapis.com/bar (a prefix)
    and
      foo.googleapis.com/bar/baz (a metric)
    will result in an error because both match the metric
      foo.googleapis.com/bar/baz.
    
    Further, using the metric type prefixes
      foo.googleapis.com/bar/baz (a metric)
    and
      foo.googleapis.com/bar/baz_count (a metric)
    will result in an error because both match the metric
      foo.googleapis.com/bar/baz_count.
    
    While the first pitfall could be expected by the user, the latter will
    come as a complete surprise to anyone who is not aware that
    stackdriver-exporter internally uses an MQL query in the form of
      metric.type = starts_with("<prefix>")
    to filter the metrics.
    
    Avoid this by sanitizing the provided metric type prefixes in the
    following way:
    - Drop any duplicate prefixes
    - Sort the prefixes (required by the next step)
    - Drop any prefixes that start with another prefix present in the input
    
    Signed-off-by: Edwin Mackenzie-Owen <edwin.mowen@gmail.com>
    sysedwinistrator committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    b3247d4 View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2024

  1. Remove condition that will never be true

    In alphanumerically sorted list of strings,
    abcdef
    will never come before
    abc.
    
    Signed-off-by: Edwin Mackenzie-Owen <edwin.mowen@gmail.com>
    sysedwinistrator committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    4ae8653 View commit details
    Browse the repository at this point in the history
  2. Add test for metrics prefix sanitization

    Signed-off-by: Edwin Mackenzie-Owen <edwin.mowen@gmail.com>
    sysedwinistrator committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    4d76015 View commit details
    Browse the repository at this point in the history