Skip to content

Commit

Permalink
Add additional logic for these disable variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rivToadd committed Mar 7, 2024
1 parent 305f6f7 commit f3f67df
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/manifests/collector/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,25 @@ func Annotations(instance v1beta1.OpenTelemetryCollector) (map[string]string, er
// new map every time, so that we don't touch the instance's annotations
annotations := map[string]string{}

var enableAnnotations bool
// enableAnnotations is true only if both disable variables are false.
// DisableAutomaticPrometheusAnnotations takes precedence over DisablePrometheusAnnotations.
if instance.Spec.Observability.Metrics.DisableAutomaticPrometheusAnnotations {
enableAnnotations = !instance.Spec.Observability.Metrics.DisableAutomaticPrometheusAnnotations
} else if instance.Spec.Observability.Metrics.DisablePrometheusAnnotations {
enableAnnotations = !instance.Spec.Observability.Metrics.DisablePrometheusAnnotations
} else {
enableAnnotations = true
}
if enableAnnotations {
// Set default Prometheus annotations
annotations["prometheus.io/scrape"] = "true"
annotations["prometheus.io/port"] = "8888"
annotations["prometheus.io/path"] = "/metrics"
}

// Enable Prometheus annotations by default if DisablePrometheusAnnotations|DisableAutomaticPrometheusAnnotations is nil or true
if !instance.Spec.Observability.Metrics.DisablePrometheusAnnotations || !instance.Spec.Observability.Metrics.DisableAutomaticPrometheusAnnotations {
if !instance.Spec.Observability.Metrics.DisableAutomaticPrometheusAnnotations {
// Set default Prometheus annotations
annotations["prometheus.io/scrape"] = "true"
annotations["prometheus.io/port"] = "8888"
Expand Down

0 comments on commit f3f67df

Please sign in to comment.