diff --git a/.chloggen/3474.yaml b/.chloggen/3474.yaml new file mode 100755 index 0000000000..aa03078ba8 --- /dev/null +++ b/.chloggen/3474.yaml @@ -0,0 +1,18 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Make ServiceMonitor for operator metrics optional and disable it by default + +# One or more tracking issues related to the change +issues: [3474] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + Add `--create-sm-operator-metrics` flag to create a ServiceMonitor for the operator metrics. + This is disabled by default, which is a breaking change, because it was enabled by default in 0.113.0 and 0.114.0. \ No newline at end of file diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index b27f23e40e..1233039d08 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -482,6 +482,7 @@ spec: - --openshift-create-dashboard=true - --feature-gates=+operator.observability.prometheus - --enable-cr-metrics=true + - --create-sm-operator-metrics=true env: - name: SERVICE_ACCOUNT_NAME valueFrom: diff --git a/config/overlays/openshift/manager-patch.yaml b/config/overlays/openshift/manager-patch.yaml index 57b097ca29..dd5718fc27 100644 --- a/config/overlays/openshift/manager-patch.yaml +++ b/config/overlays/openshift/manager-patch.yaml @@ -9,4 +9,5 @@ - '--enable-go-instrumentation=true' - '--openshift-create-dashboard=true' - '--feature-gates=+operator.observability.prometheus' - - '--enable-cr-metrics=true' \ No newline at end of file + - '--enable-cr-metrics=true' + - '--create-sm-operator-metrics=true' diff --git a/main.go b/main.go index cb83e6a920..05d246964a 100644 --- a/main.go +++ b/main.go @@ -126,6 +126,7 @@ func main() { enableNodeJSInstrumentation bool enableJavaInstrumentation bool enableCRMetrics bool + createSMOperatorMetrics bool collectorImage string targetAllocatorImage string operatorOpAMPBridgeImage string @@ -165,6 +166,7 @@ func main() { pflag.BoolVar(&enableNodeJSInstrumentation, constants.FlagNodeJS, true, "Controls whether the operator supports nodejs auto-instrumentation") pflag.BoolVar(&enableJavaInstrumentation, constants.FlagJava, true, "Controls whether the operator supports java auto-instrumentation") pflag.BoolVar(&enableCRMetrics, constants.FlagCRMetrics, false, "Controls whether exposing the CR metrics is enabled") + pflag.BoolVar(&createSMOperatorMetrics, "create-sm-operator-metrics", false, "Create a ServiceMonitor for the operator metrics") stringFlagOrEnv(&collectorImage, "collector-image", "RELATED_IMAGE_COLLECTOR", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:%s", v.OpenTelemetryCollector), "The default OpenTelemetry collector image. This image is used when no image is specified in the CustomResource.") stringFlagOrEnv(&targetAllocatorImage, "target-allocator-image", "RELATED_IMAGE_TARGET_ALLOCATOR", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/target-allocator:%s", v.TargetAllocator), "The default OpenTelemetry target allocator image. This image is used when no image is specified in the CustomResource.") @@ -230,6 +232,7 @@ func main() { "enable-nodejs-instrumentation", enableNodeJSInstrumentation, "enable-java-instrumentation", enableJavaInstrumentation, "create-openshift-dashboard", createOpenShiftDashboard, + "create-sm-operator-metrics", createSMOperatorMetrics, "zap-message-key", encodeMessageKey, "zap-level-key", encodeLevelKey, "zap-time-key", encodeTimeKey, @@ -424,7 +427,7 @@ func main() { os.Exit(1) } - if cfg.PrometheusCRAvailability() == prometheus.Available { + if cfg.PrometheusCRAvailability() == prometheus.Available && createSMOperatorMetrics { operatorMetrics, opError := operatormetrics.NewOperatorMetrics(mgr.GetConfig(), scheme, ctrl.Log.WithName("operator-metrics-sm")) if opError != nil { setupLog.Error(opError, "Failed to create the operator metrics SM")