Allow OTel metrics to work with postgres versions greater than 17. If…#4329
Allow OTel metrics to work with postgres versions greater than 17. If…#4329dsessler7 merged 1 commit intoCrunchyData:mainfrom
Conversation
jmckulk
left a comment
There was a problem hiding this comment.
One naming ⛏️but functionally looks good
| // OTel metrics or postgres_exporter are enabled. | ||
| func (r *Reconciler) reconcileExporterSqlSetup(ctx context.Context, | ||
| cluster *v1beta1.PostgresCluster) (string, error) { | ||
| if !collector.OpenTelemetryMetricsEnabled(ctx, cluster) { |
There was a problem hiding this comment.
I think if exporter would make more sense here since we are only talking about exporter specific things (comments, warnings, setup) ⛏️
There was a problem hiding this comment.
Not sure I follow... In this function the "Exporter" in reconcileExporterSqlSetup refers to both/either OTel and/or postgres_exporter. If the OTel metrics feature is enabled, it takes precedence (even if postgres_exporter is enabled). If OTel metrics isn't enabled, we get the setup for postgres_exporter.
There was a problem hiding this comment.
That makes sense. I should have said if postgres_exporter... something like this:
if pgmonitor.ExporterEnabled(ctx, cluster) {
# do some postgres_exporter specific things
return metrics for postgres_exporter
}
# default to otel
return metrics for otel
It feels weird to me to have
if !otel {
# do postgres_exporter things
}
There was a problem hiding this comment.
Well, that's just the thing, if OTel metrics is enabled it will always be used, even if postgres_exporter is also enabled. Also, pgmonitor.ExporterEnabled checks that at least one of OTel metrics or postgres_exporter are enabled (not only postgres_exporter).
I guess I could change it to more of a guard clause for OTel and make postgres_exporter the "default":
if otel {
return metricsSetupForOTelCollector, nil
}
# do postgres_exporter stuff
But then we're kinda splitting hairs here
There was a problem hiding this comment.
Definitely splitting hairs 👍
… postgres_exporter is used with postgres versions greater than 17, create a warning event and set the setup.sql blank.
7f2cc48 to
9fb4615
Compare
… postgres_exporter is used with postgres versions greater than 17, create a warning event and set the setup.sql blank.
Checklist:
Type of Changes:
What is the current behavior (link to any open issues here)?
Currently, if you are using either metrics exporter (OTel or
postgres_exporter) with a postgres version greater than 17, you will get a reconciler error and metrics will not work.What is the new behavior (if this is a feature change)?
You can now get metrics with pg > 17 if you use OTel as your exporter. We will not support
postgres_exporterwith pg versions greater than 17. If you attempt to usepostgres_exporterwith pg > 17, you will see a warning event and the metrics will essentially be turned off.Other Information: