diff --git a/common/common.go b/common/common.go index ce32505267412..c5eb15566760a 100644 --- a/common/common.go +++ b/common/common.go @@ -273,8 +273,6 @@ const ( EnvEventReporterReplicas = "EVENT_REPORTER_REPLICAS" // EnvEventReporterShard is the shard number that should be handled by reporter EnvEventReporterShard = "EVENT_REPORTER_SHARD" - // EnvEventReporterDetailedMetrics is bool value that enables sending details metrics with resource kind, app names, etc. - EnvEventReporterDetailedMetrics = "EVENT_REPORTER_DETAILED_METRICS" ) // Config Management Plugin related constants diff --git a/event_reporter/metrics/metrics.go b/event_reporter/metrics/metrics.go index 290a65dbf6eeb..0c7861b28589f 100644 --- a/event_reporter/metrics/metrics.go +++ b/event_reporter/metrics/metrics.go @@ -2,9 +2,7 @@ package metrics import ( "fmt" - argocommon "github.com/argoproj/argo-cd/v2/common" "github.com/argoproj/argo-cd/v2/event_reporter/sharding" - "github.com/argoproj/argo-cd/v2/util/env" "net/http" "strconv" "time" @@ -18,7 +16,6 @@ import ( type MetricsServer struct { *http.Server shard string - detailedMetricsEnabled bool redisRequestCounter *prometheus.CounterVec redisRequestHistogram *prometheus.HistogramVec queueSizeCounter *prometheus.GaugeVec @@ -28,8 +25,6 @@ type MetricsServer struct { eventProcessingDurationHistogram *prometheus.HistogramVec } -const notDetailedMetricPlaceholderLabel = "not_reported" - type MetricEventType string const ( @@ -94,10 +89,10 @@ var ( eventProcessingDurationHistogram = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "cf_e_reporter_event_processing_duration", - Help: "Event processing duration.", + Help: "Application event processing duration.", Buckets: []float64{0.1, 0.25, .5, 1, 2, 3, 4, 5, 7, 10, 15, 20}, }, - []string{"reporter_shard", "application", "kind", "metric_event_type"}, + []string{"reporter_shard", "application", "metric_event_type"}, ) ) @@ -122,7 +117,6 @@ func NewMetricsServer(host string, port int) *MetricsServer { registry.MustRegister(eventProcessingDurationHistogram) shard := sharding.GetShardNumber() - detailedMetrics := env.ParseBoolFromEnv(argocommon.EnvEventReporterDetailedMetrics, false) return &MetricsServer{ Server: &http.Server{ @@ -130,7 +124,6 @@ func NewMetricsServer(host string, port int) *MetricsServer { Handler: mux, }, shard: strconv.FormatInt(int64(shard), 10), - detailedMetricsEnabled: detailedMetrics, queueSizeCounter: queueSizeCounter, appEventsCounter: appEventsCounter, erroredEventsCounter: erroredEventsCounter, @@ -164,10 +157,6 @@ func (m *MetricsServer) IncCachedIgnoredEventsCounter(metricEventType MetricEven m.cachedIgnoredEventsCounter.WithLabelValues(m.shard, string(metricEventType), application).Inc() } -func (m *MetricsServer) ObserveEventProcessingDurationHistogramDuration(application string, managedResourceKind string, metricEventType MetricEventType, duration time.Duration) { - if m.detailedMetricsEnabled { - m.eventProcessingDurationHistogram.WithLabelValues(m.shard, application, managedResourceKind, string(metricEventType)).Observe(duration.Seconds()) - } else { - m.eventProcessingDurationHistogram.WithLabelValues(m.shard, notDetailedMetricPlaceholderLabel, notDetailedMetricPlaceholderLabel, string(metricEventType)).Observe(duration.Seconds()) - } +func (m *MetricsServer) ObserveEventProcessingDurationHistogramDuration(application string, metricEventType MetricEventType, duration time.Duration) { + m.eventProcessingDurationHistogram.WithLabelValues(m.shard, application, string(metricEventType)).Observe(duration.Seconds()) } diff --git a/event_reporter/reporter/application_event_reporter.go b/event_reporter/reporter/application_event_reporter.go index c8075f332fd25..01a647a9caf8b 100644 --- a/event_reporter/reporter/application_event_reporter.go +++ b/event_reporter/reporter/application_event_reporter.go @@ -39,8 +39,6 @@ var ( resourceEventCacheExpiration = time.Minute * time.Duration(env.ParseNumFromEnv(argocommon.EnvResourceEventCacheDuration, 20, 0, math.MaxInt32)) ) -const ApplicationKind = "Application" - type applicationEventReporter struct { cache *servercache.Cache codefreshClient codefresh.CodefreshClient @@ -220,7 +218,7 @@ func (s *applicationEventReporter) StreamApplicationEvents( return err } reconcileDuration := time.Since(startTime) - s.metricsServer.ObserveEventProcessingDurationHistogramDuration(a.Name, ApplicationKind, metrics.MetricChildAppEventType, reconcileDuration) + s.metricsServer.ObserveEventProcessingDurationHistogramDuration(a.Name, metrics.MetricChildAppEventType, reconcileDuration) } else { logCtx.Info("processing as root application") // will get here only for root applications (not managed as a resource by another application) @@ -241,7 +239,7 @@ func (s *applicationEventReporter) StreamApplicationEvents( return fmt.Errorf("failed to send event for root application %s/%s: %w", a.Namespace, a.Name, err) } reconcileDuration := time.Since(startTime) - s.metricsServer.ObserveEventProcessingDurationHistogramDuration(a.Name, ApplicationKind, metrics.MetricParentAppEventType, reconcileDuration) + s.metricsServer.ObserveEventProcessingDurationHistogramDuration(a.Name, metrics.MetricParentAppEventType, reconcileDuration) } revisionMetadata, _ := s.getApplicationRevisionDetails(ctx, a, getOperationRevision(a)) @@ -256,14 +254,11 @@ func (s *applicationEventReporter) StreamApplicationEvents( s.metricsServer.IncCachedIgnoredEventsCounter(metrics.MetricResourceEventType, a.Name) continue } - startTime := time.Now() err := s.processResource(ctx, rs, a, logCtx, ts, desiredManifests, appTree, manifestGenErr, nil, revisionMetadata, appInstanceLabelKey, trackingMethod, nil) if err != nil { s.metricsServer.IncErroredEventsCounter(metrics.MetricResourceEventType, metrics.MetricEventUnknownErrorType, a.Name) return err } - reconcileDuration := time.Since(startTime) - s.metricsServer.ObserveEventProcessingDurationHistogramDuration(a.Name, rs.Kind, metrics.MetricResourceEventType, reconcileDuration) } return nil }