Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling the creation of the SM for operator metrics #3509

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: enhancement

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
note: Make ServiceMonitor for operator metrics optional
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 to avoid breaking changes.
Comment on lines +17 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add create-sm-operator-metrics flag to create a ServiceMonitor for the operator metrics.
This is disabled by default to avoid breaking changes.
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 @@ -99,7 +99,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-11-27T11:54:33Z"
createdAt: "2024-12-03T12:59:03Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment here? Maybe just linking the pr?

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
Loading