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

metric: truncate help text in prom output #134724

Merged

Conversation

dhartunian
Copy link
Collaborator

We have some long multiline help text defined for metrics that makes the prometheus output quite large. This change automatically truncates help text at the first newline during prometheus output. We can still access the full text in our docs and code.

Resolves: CRDB-43497
Epic: None

Release note (ops change): the metrics scrape HTTP endpoint at / _status/vars will now truncate HELP text at the first newline, reducing the metadata for metrics with large descriptions. Customers can still access these descriptions via our docs.

@dhartunian dhartunian requested review from a team as code owners November 8, 2024 20:48
@dhartunian dhartunian requested review from arjunmahishi and aa-joshi and removed request for a team November 8, 2024 20:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@@ -125,6 +126,9 @@ func (pm *PrometheusExporter) ScrapeRegistry(registry *Registry, includeChildMet
func (pm *PrometheusExporter) printAsText(w io.Writer, contentType expfmt.Format) error {
enc := expfmt.NewEncoder(w, contentType)
for _, family := range pm.families {
if left, _, found := strings.Cut(*family.Help, "\n"); found {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to terminate at the first . instead of \n? That will guarantee that the sentence is complete.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the nudge. I took a different approach that cleans metrics up when they get added to a registry. This will clean up the whitespace (newlines/indents) and truncate at the first sentence.

@dhartunian dhartunian force-pushed the reduce-help-text-output-for-metrics branch from b0e74b7 to 9a950e9 Compare November 11, 2024 17:57
@dhartunian dhartunian requested a review from a team as a code owner November 11, 2024 17:57
We have some long multiline help text defined for metrics that makes
the prometheus output quite large. This change cleans up whitespace
and trunactes the help text at the first period when  the metric is
added to the registry. We can still access the full text in our docs
and code.

Resolves: CRDB-43497
Epic: None

Release note (ops change): the metrics scrape HTTP endpoint at `/
_status/vars` will now truncate HELP text at the first sentence,
reducing the metadata for metrics with large descriptions. Customers
can still access these descriptions via our docs.
@dhartunian dhartunian force-pushed the reduce-help-text-output-for-metrics branch from 9a950e9 to fdaf7fe Compare November 12, 2024 18:25
@dhartunian dhartunian added the backport-24.3.x Flags PRs that need to be backported to 24.3 label Nov 12, 2024
@dhartunian
Copy link
Collaborator Author

TFTR! I moved the truncation to the prometheus exporter so that it wouldn't affect docs generation.

bors r=arjunmahishi

@craig craig bot merged commit 2cbed34 into cockroachdb:master Nov 12, 2024
23 checks passed
Copy link

blathers-crl bot commented Nov 12, 2024

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error setting reviewers, but backport branch blathers/backport-release-24.3-134724 is ready: POST https://api.github.com/repos/cockroachdb/cockroach/pulls/135021/requested_reviewers: 422 Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the cockroachdb/cockroach repository. []

Backport to branch 24.3.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-24.3.x Flags PRs that need to be backported to 24.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants