File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 8
8
"context"
9
9
"os"
10
10
11
+ "github.com/crunchydata/postgres-operator/internal/collector"
11
12
"github.com/crunchydata/postgres-operator/internal/logging"
12
13
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
13
14
)
@@ -27,6 +28,11 @@ func GetQueriesConfigDir(ctx context.Context) string {
27
28
28
29
// ExporterEnabled returns true if the monitoring exporter is enabled
29
30
func 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
+ }
30
36
if cluster .Spec .Monitoring == nil {
31
37
return false
32
38
}
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
10
10
11
11
"gotest.tools/v3/assert"
12
12
13
+ "github.com/crunchydata/postgres-operator/internal/feature"
14
+ "github.com/crunchydata/postgres-operator/internal/testing/require"
13
15
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
14
16
)
15
17
@@ -26,4 +28,19 @@ func TestExporterEnabled(t *testing.T) {
26
28
27
29
cluster .Spec .Monitoring .PGMonitor .Exporter = & v1beta1.ExporterSpec {}
28
30
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 ))
29
46
}
You can’t perform that action at this time.
0 commit comments