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

Optionally print OM created lines #1408

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Optionally print OM created lines #1408

wants to merge 2 commits into from

Conversation

ArthurSens
Copy link
Member

@ArthurSens ArthurSens commented Dec 12, 2023

This PR adds an extra option to print _created lines when OpenMetrics is the chosen exposition format. It's implemented following the conditional option added in prometheus/common#504.

@ArthurSens ArthurSens changed the title Optionally print OM created lines [WIP] Optionally print OM created lines Dec 12, 2023
@ArthurSens ArthurSens changed the title [WIP] Optionally print OM created lines Optionally print OM created lines Feb 2, 2024
@ArthurSens ArthurSens force-pushed the om-created-lines branch 3 times, most recently from e930252 to 240345e Compare February 2, 2024 18:35
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks! One minor nit, otherwise well done!

prometheus/promhttp/http.go Outdated Show resolved Hide resolved
@ArthurSens ArthurSens force-pushed the om-created-lines branch 2 times, most recently from 33ed3e6 to e9c6f77 Compare February 18, 2024 18:33
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Epic, proposed some improvements, thanks!

prometheus/promhttp/http.go Outdated Show resolved Hide resolved
prometheus/promhttp/http.go Outdated Show resolved Hide resolved
prometheus/promhttp/http.go Outdated Show resolved Hide resolved
prometheus/promhttp/http.go Outdated Show resolved Hide resolved
Comment on lines 396 to 397
// possible options during content negotiation. Note that Prometheus
// 2.5.0+ will negotiate OpenMetrics as first priority. OpenMetrics is
// the only way to transmit exemplars. However, the move to OpenMetrics
// is not completely transparent. Most notably, the values of "quantile"
// labels of Summaries and "le" labels of Histograms are formatted with
// a trailing ".0" if they would otherwise look like integer numbers
// (which changes the identity of the resulting series on the Prometheus
// server).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// possible options during content negotiation. Note that Prometheus
// 2.5.0+ will negotiate OpenMetrics as first priority. OpenMetrics is
// the only way to transmit exemplars. However, the move to OpenMetrics
// is not completely transparent. Most notably, the values of "quantile"
// labels of Summaries and "le" labels of Histograms are formatted with
// a trailing ".0" if they would otherwise look like integer numbers
// (which changes the identity of the resulting series on the Prometheus
// server).
// possible options during content negotiation.
//
// Note that Prometheus 2.5.0+ might negotiate OpenMetrics Text format
// as first priority unless user uses custom scrape protocol prioritization or
// histograms feature is enabled (then Prometheus proto format is prioritized,
// which client_golang supports).
//
// The main reason for enabling OpenMetrics Text was to enable exemplars,
// but Prometheus proto has that as feature as well.
//
// However, the move to OpenMetrics is not completely transparent. Most notably,
// the values of "quantile" labels of Summaries and "le" labels of Histograms are
// formatted with a trailing ".0" if they would otherwise look like integer numbers
// (which changes the identity of the resulting series on the Prometheus
// server).
//
// See other options in OpenMetricsOptions to learn how to enable some special
// features e.g. potentially dangerous created timestamp series.

Copy link
Member Author

Choose a reason for hiding this comment

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

	// The main reason for enabling OpenMetrics Text was to enable exemplars,
	// but Prometheus proto has that as feature as well.

this part seems a bit out of place, not adding much to the comment 🤔, is it ok to not add this part?

// is recommended to enable the feature flag in Prometheus, otherwise enabling
// _created lines will result in increased cardinality and no improvements
// in reset detection.
EnableOpenMetricsCreatedMetrics bool
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
EnableOpenMetricsCreatedMetrics bool
EnableCreatedSeries bool

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmmmm, future versions of OM might not expose them as a series. What do you think about EnableCreatedTimestamps?

prometheus/promhttp/http.go Outdated Show resolved Hide resolved
@ArthurSens
Copy link
Member Author

We need prometheus/common v0.49.0 for this feature, but this version of prometheus/common requires go 1.21.

Therefore, the PR is blocked until we drop support for go 1.20

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
@ArthurSens
Copy link
Member Author

After quite some work to unblock this, this is finally ready :)

Do you want to review again or should I just merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OpenMetrics OpenMetrics v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants