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

fix(metrics): Parse serialized gauge values #640

Merged
merged 2 commits into from
Feb 7, 2024
Merged

Conversation

loewenheim
Copy link
Contributor

@loewenheim loewenheim commented Feb 5, 2024

Gauges are serialized as last:min:max:sum:count. When parsing a gauge as a Metric, we only want the last value, so we need to take care to discard everything after the first :.

See #639.

@loewenheim loewenheim self-assigned this Feb 5, 2024
fn test_regression_parse_statsd() {
let payload = "docker.net.bytes_rcvd:27763.20237096717:27763.20237096717:27763.20237096717:27763.20237096717:1|g|#container_id:97df61f5c55b58ec9c04da3e03edc8a875ec90eb405eb5645ad9a86d0a7cd3ee,container_name:app_sidekiq_1,docker_image:ghcr.io/mastodon/mastodon:nightly.2024-02-02-security,docker_network:app_internal_network,git.commit.sha:1726085db5cd73dd30953da858f9887bcc90b958,git.repository_url:https://github.com/mastodon/mastodon,host:aaaa,image_name:ghcr.io/mastodon/mastodon,image_tag:nightly.2024-02-02-security,runtime:docker,short_image:mastodon,source_type_name:System,environment:production|T1707081890";
let metric = Metric::parse_statsd(payload).unwrap();
assert_eq!(metric.name, "docker.net.bytes_rcvd");
Copy link
Member

Choose a reason for hiding this comment

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

it we really want to preserve "roundtrips" (which this does not do fully), we should check the fully serialized metric.
also no need to put all the tags into this test :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question for me is also whether we should be more general in parsing: do we want to discard everything but the last value, or would it make sense to parse and preserve them?

Copy link

codecov bot commented Feb 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ea6375d) 73.23% compared to head (bded474) 73.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #640      +/-   ##
==========================================
+ Coverage   73.23%   73.33%   +0.09%     
==========================================
  Files          62       62              
  Lines        7550     7563      +13     
==========================================
+ Hits         5529     5546      +17     
+ Misses       2021     2017       -4     

@loewenheim loewenheim requested a review from Swatinem February 6, 2024 16:01
@loewenheim loewenheim merged commit 93c4b2f into master Feb 7, 2024
13 checks passed
@loewenheim loewenheim deleted the fix/parse-gauges branch February 7, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants