File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 88 "context"
99 "os"
1010
11+ "github.com/crunchydata/postgres-operator/internal/collector"
1112 "github.com/crunchydata/postgres-operator/internal/logging"
1213 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1314)
@@ -27,6 +28,11 @@ func GetQueriesConfigDir(ctx context.Context) string {
2728
2829// ExporterEnabled returns true if the monitoring exporter is enabled
2930func ExporterEnabled (ctx context.Context , cluster * v1beta1.PostgresCluster ) bool {
31+ // If OpenTelemetry metrics are enabled for this cluster, that takes precedence
32+ // over the postgres_exporter metrics.
33+ if collector .OpenTelemetryMetricsEnabled (ctx , cluster ) {
34+ return false
35+ }
3036 if cluster .Spec .Monitoring == nil {
3137 return false
3238 }
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
1010
1111 "gotest.tools/v3/assert"
1212
13+ "github.com/crunchydata/postgres-operator/internal/feature"
14+ "github.com/crunchydata/postgres-operator/internal/testing/require"
1315 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1416)
1517
@@ -26,4 +28,19 @@ func TestExporterEnabled(t *testing.T) {
2628
2729 cluster .Spec .Monitoring .PGMonitor .Exporter = & v1beta1.ExporterSpec {}
2830 assert .Assert (t , ExporterEnabled (ctx , cluster ))
31+
32+ // Enabling the OpenTelemetryMetrics is not sufficient to disable the exporter
33+ gate := feature .NewGate ()
34+ assert .NilError (t , gate .SetFromMap (map [string ]bool {
35+ feature .OpenTelemetryMetrics : true ,
36+ }))
37+ ctx = feature .NewContext (ctx , gate )
38+ assert .Assert (t , ExporterEnabled (ctx , cluster ))
39+
40+ require .UnmarshalInto (t , & cluster .Spec , `{
41+ instrumentation: {
42+ logs: { retentionPeriod: 5h },
43+ },
44+ }` )
45+ assert .Assert (t , ! ExporterEnabled (ctx , cluster ))
2946}
You can’t perform that action at this time.
0 commit comments