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(aggregated-metrics): correctly create logfmt string #14124

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

svennergr
Copy link
Contributor

What this PR does / why we need it:

The aggregated metrics added in #13731 currently create the entry to be logged in logfmt format. This PR correctly adds quotes to strings being added, and adds a util function to humanize bytes without whitespaces. Basically it moves the implementation from metrics.go to metrics_helper.go.

Aggregated metrics entries currently look like:

ts=1726132612901000000 bytes=107 B count=1 service_name=service-name

Especially notice the 107 B which breaks the "correct" logfmt format.

With this PR the entry will look like:

ts=1726132612901000000 bytes=107B count=1 service_name="service-name"

@svennergr svennergr requested a review from a team as a code owner September 12, 2024 10:14
Comment on lines -246 to -249
func humanizeBytes(val uint64) string {
return strings.Replace(humanize.Bytes(val), " ", "", 1)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically just moved this to utils.HumanizeBytes

Copy link
Collaborator

@trevorwhitney trevorwhitney left a comment

Choose a reason for hiding this comment

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

thank you!

@trevorwhitney trevorwhitney merged commit 63e84b4 into main Sep 12, 2024
61 checks passed
@trevorwhitney trevorwhitney deleted the svennergr/fix-bytes-in-aggregation branch September 12, 2024 15:28
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