Skip to content

Commit

Permalink
Allow disabling the creation of the SM for operator metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Israel Blancas <[email protected]>
  • Loading branch information
iblancasa committed Jan 8, 2025
1 parent bfead6f commit c69a21f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .chloggen/3474.yaml
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion config/overlays/openshift/manager-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
- '--enable-go-instrumentation=true'
- '--openshift-create-dashboard=true'
- '--feature-gates=+operator.observability.prometheus'
- '--enable-cr-metrics=true'
- '--enable-cr-metrics=true'
- '--create-sm-operator-metrics=true'
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func main() {
enableNodeJSInstrumentation bool
enableJavaInstrumentation bool
enableCRMetrics bool
createSMOperatorMetrics bool
collectorImage string
targetAllocatorImage string
operatorOpAMPBridgeImage string
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit c69a21f

Please sign in to comment.