-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
metric: truncate help text in prom output #134724
Conversation
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
b0e74b7
to
9a950e9
Compare
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.
9a950e9
to
fdaf7fe
Compare
TFTR! I moved the truncation to the prometheus exporter so that it wouldn't affect docs generation. bors r=arjunmahishi |
Encountered an error creating backports. Some common things that can go wrong:
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. |
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.