Skip to content

Commit 62db99b

Browse files
committed
Adding disableautomaticprometheues
1 parent 2655b58 commit 62db99b

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, 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: Changing one of the fields to follow naming conventions with lowerCamelCase
9+
10+
# One or more tracking issues related to the change
11+
issues: [2608]
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:

apis/v1alpha1/collector_webhook.go

+4
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ func (c CollectorWebhook) validate(ctx context.Context, r *OpenTelemetryCollecto
260260
maxReplicas = r.Spec.MaxReplicas
261261
}
262262

263+
if r.Spec.Observability.Metrics.DisablePrometheusAnnotations {
264+
warnings = append(warnings, "DisablePrometheusAnnotations is deprecated, use DisableAutomaticPrometheusAnnotations instead")
265+
}
266+
263267
var minReplicas *int32
264268
if r.Spec.Autoscaler != nil && r.Spec.Autoscaler.MinReplicas != nil {
265269
minReplicas = r.Spec.Autoscaler.MinReplicas

apis/v1alpha1/opentelemetrycollector_types.go

+7
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,14 @@ type MetricsConfigSpec struct {
527527
//
528528
// +optional
529529
// +kubebuilder:validation:Optional
530+
// Deprecated: use Spec.Observability.Metrics.DisableAutomaticPrometheusAnnotations instead.
530531
DisablePrometheusAnnotations bool `json:"DisablePrometheusAnnotations,omitempty"`
532+
// DisableAutomaticPrometheusAnnotations controls the automatic addition of default Prometheus annotations
533+
// ('prometheus.io/scrape', 'prometheus.io/port', and 'prometheus.io/path')
534+
//
535+
// +optional
536+
// +kubebuilder:validation:Optional
537+
DisableAutomaticPrometheusAnnotations bool `json:"disableAutomaticPrometheusAnnotations,omitempty"`
531538
}
532539

533540
// ObservabilitySpec defines how telemetry data gets handled.

internal/manifests/collector/annotations.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func Annotations(instance v1beta1.OpenTelemetryCollector) (map[string]string, er
2727
// new map every time, so that we don't touch the instance's annotations
2828
annotations := map[string]string{}
2929

30-
// Enable Prometheus annotations by default if DisablePrometheusAnnotations is nil or true
31-
if !instance.Spec.Observability.Metrics.DisablePrometheusAnnotations {
30+
// Enable Prometheus annotations by default if DisablePrometheusAnnotations|DisableAutomaticPrometheusAnnotations is nil or true
31+
if !instance.Spec.Observability.Metrics.DisablePrometheusAnnotations || !instance.Spec.Observability.Metrics.DisableAutomaticPrometheusAnnotations {
3232
// Set default Prometheus annotations
3333
annotations["prometheus.io/scrape"] = "true"
3434
annotations["prometheus.io/port"] = "8888"

internal/manifests/collector/annotations_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func TestNonDefaultPodAnnotation(t *testing.T) {
7373
Observability: v1alpha1.ObservabilitySpec{
7474
Metrics: v1alpha1.MetricsConfigSpec{
7575
DisablePrometheusAnnotations: true,
76+
DisableAutomaticPrometheusAnnotations: true,
7677
},
7778
},
7879
},

0 commit comments

Comments
 (0)