Skip to content

Commit c69a21f

Browse files
committed
Allow disabling the creation of the SM for operator metrics
Signed-off-by: Israel Blancas <[email protected]>
1 parent bfead6f commit c69a21f

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

.chloggen/3474.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: breaking
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Make ServiceMonitor for operator metrics optional and disable it by default
9+
10+
# One or more tracking issues related to the change
11+
issues: [3474]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext: |
17+
Add `--create-sm-operator-metrics` flag to create a ServiceMonitor for the operator metrics.
18+
This is disabled by default, which is a breaking change, because it was enabled by default in 0.113.0 and 0.114.0.

bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ spec:
482482
- --openshift-create-dashboard=true
483483
- --feature-gates=+operator.observability.prometheus
484484
- --enable-cr-metrics=true
485+
- --create-sm-operator-metrics=true
485486
env:
486487
- name: SERVICE_ACCOUNT_NAME
487488
valueFrom:

config/overlays/openshift/manager-patch.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
- '--enable-go-instrumentation=true'
1010
- '--openshift-create-dashboard=true'
1111
- '--feature-gates=+operator.observability.prometheus'
12-
- '--enable-cr-metrics=true'
12+
- '--enable-cr-metrics=true'
13+
- '--create-sm-operator-metrics=true'

main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func main() {
126126
enableNodeJSInstrumentation bool
127127
enableJavaInstrumentation bool
128128
enableCRMetrics bool
129+
createSMOperatorMetrics bool
129130
collectorImage string
130131
targetAllocatorImage string
131132
operatorOpAMPBridgeImage string
@@ -165,6 +166,7 @@ func main() {
165166
pflag.BoolVar(&enableNodeJSInstrumentation, constants.FlagNodeJS, true, "Controls whether the operator supports nodejs auto-instrumentation")
166167
pflag.BoolVar(&enableJavaInstrumentation, constants.FlagJava, true, "Controls whether the operator supports java auto-instrumentation")
167168
pflag.BoolVar(&enableCRMetrics, constants.FlagCRMetrics, false, "Controls whether exposing the CR metrics is enabled")
169+
pflag.BoolVar(&createSMOperatorMetrics, "create-sm-operator-metrics", false, "Create a ServiceMonitor for the operator metrics")
168170

169171
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.")
170172
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() {
230232
"enable-nodejs-instrumentation", enableNodeJSInstrumentation,
231233
"enable-java-instrumentation", enableJavaInstrumentation,
232234
"create-openshift-dashboard", createOpenShiftDashboard,
235+
"create-sm-operator-metrics", createSMOperatorMetrics,
233236
"zap-message-key", encodeMessageKey,
234237
"zap-level-key", encodeLevelKey,
235238
"zap-time-key", encodeTimeKey,
@@ -424,7 +427,7 @@ func main() {
424427
os.Exit(1)
425428
}
426429

427-
if cfg.PrometheusCRAvailability() == prometheus.Available {
430+
if cfg.PrometheusCRAvailability() == prometheus.Available && createSMOperatorMetrics {
428431
operatorMetrics, opError := operatormetrics.NewOperatorMetrics(mgr.GetConfig(), scheme, ctrl.Log.WithName("operator-metrics-sm"))
429432
if opError != nil {
430433
setupLog.Error(opError, "Failed to create the operator metrics SM")

0 commit comments

Comments
 (0)