-
Notifications
You must be signed in to change notification settings - Fork 30
🐛 Remove cluster label #142
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ const ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel = "source" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsOriginalSourceLabel = "original_source" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel = "cluster" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsConsumerLabel = "consumer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel = "type" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSubResourceLabel = "subresource" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsActionLabel = "action" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,7 +31,7 @@ const noneOriginalSource = "none" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudeventsReceivedMetricsLabels - Array of labels added to cloudevents received metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var cloudeventsReceivedMetricsLabels = []string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel, // source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel, // cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsConsumerLabel, // consumer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel, // data type, e.g. manifests, manifestbundles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSubResourceLabel, // subresource, eg, spec or status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsActionLabel, // action, eg, create, update, delete, resync_request, resync_response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -41,7 +41,7 @@ var cloudeventsReceivedMetricsLabels = []string{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var cloudeventsSentMetricsLabels = []string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel, // source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsOriginalSourceLabel, // original source, if no, set to "none" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel, // cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsConsumerLabel, // consumer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel, // data type, e.g. manifests, manifestbundles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSubResourceLabel, // subresource, eg, spec or status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsActionLabel, // action, eg, create, update, delete, resync_request, resync_response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -50,7 +50,7 @@ var cloudeventsSentMetricsLabels = []string{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudeventsResyncMetricsLabels - Array of labels added to cloudevents resync metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var cloudeventsResyncMetricsLabels = []string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel, // source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel, // cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsConsumerLabel, // consumer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel, // data type, e.g. manifests, manifestbundles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -77,10 +77,10 @@ const ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The cloudevents received counter metric is a counter with a base metric name of 'received_total' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and a help string of 'The total number of received CloudEvents.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For example, 2 CloudEvents received from source1 to agent on cluster1 with data type manifests, one for resource create, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // another for resource updatewould result in the following metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_received_total{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",subresource="spec",action="create"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_received_total{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",subresource="spec",action="update"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For example, 2 CloudEvents received from source1 to consumer1 with data type manifests, one for resource create, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // another for resource update would result in the following metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_received_total{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",subresource="spec",action="create"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_received_total{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",subresource="spec",action="update"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var cloudeventsReceivedCounterMetric = prometheus.NewCounterVec( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prometheus.CounterOpts{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subsystem: cloudeventsMetricsSubsystem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -93,9 +93,9 @@ var cloudeventsReceivedCounterMetric = prometheus.NewCounterVec( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The cloudevents sent counter metric is a counter with a base metric name of 'sent_total' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and a help string of 'The total number of sent CloudEvents.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For example, 1 cloudevent sent from source1 with data type manifestbundles for resource spec create (original source is empty), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and 2 CloudEvents sent from agent on cluster1 back to source1 for resource status update would result in the following metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_sent_total{source="source1",original_source="none",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",subresource="spec",action="create"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_sent_total{source="cluster1-work-agent",original_source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",subresource="status",action="update"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // and 2 CloudEvents sent from consumer1-work-agent back to source1 for resource status update would result in the following metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_sent_total{source="source1",original_source="none",type="io.open-cluster-management.works.v1alpha1.manifestbundles",subresource="spec",action="create"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cloudevents_sent_total{source="consumer1-work-agent",original_source="source1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",subresource="status",action="update"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var cloudeventsSentCounterMetric = prometheus.NewCounterVec( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prometheus.CounterOpts{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subsystem: cloudeventsMetricsSubsystem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -111,16 +111,16 @@ var cloudeventsSentCounterMetric = prometheus.NewCounterVec( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 2. the total sum of all observed values, exposed as 'resource_spec_resync_duration_seconds_sum' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 3. the count of events that have been observed, exposed as 'resource_spec_resync_duration_seconds_count' (identical to 'resource_spec_resync_duration_seconds_bucket{le="+Inf"}' above) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For example, 2 resource spec resync for manifests type that have been observed, one taking 0.5s and the other taking 0.7s, would result in the following metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="0.1"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="0.2"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="0.5"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="1.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="2.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="10.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="30.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests",le="+Inf"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_sum{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests"} 1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_count{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifests"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="0.1"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="0.2"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="0.5"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="1.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="2.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="10.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="30.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests",le="+Inf"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_sum{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests"} 1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_spec_resync_duration_seconds_count{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifests"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var resourceSpecResyncDurationMetric = prometheus.NewHistogramVec( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prometheus.HistogramOpts{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subsystem: resourcesMetricsSubsystem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -145,16 +145,16 @@ var resourceSpecResyncDurationMetric = prometheus.NewHistogramVec( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 2. the total sum of all observed values, exposed as 'resource_status_resync_duration_seconds_sum' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 3. the count of events that have been observed, exposed as 'resource_status_resync_duration_seconds_count' (identical to 'resource_status_resync_duration_seconds_bucket{le="+Inf"}' above) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For example, 2 resource status resync for manifestbundles type that have been observed, one taking 0.5s and the other taking 1.1s, would result in the following metrics: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="0.1"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="0.2"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="0.5"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="1.0"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="2.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="10.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="30.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="+Inf"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_sum{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles"} 1.6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_count{source="source1",cluster="cluster1",type="io.open-cluster-management.works.v1alpha1.manifestbundles"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="0.1"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="0.2"} 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="0.5"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="1.0"} 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="2.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="10.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="30.0"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_bucket{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles",le="+Inf"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_sum{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles"} 1.6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resource_status_resync_duration_seconds_count{source="source1",consumer="consumer1",type="io.open-cluster-management.works.v1alpha1.manifestbundles"} 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var resourceStatusResyncDurationMetric = prometheus.NewHistogramVec( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prometheus.HistogramOpts{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subsystem: resourcesMetricsSubsystem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -225,50 +225,56 @@ func ResetCloudEventsMetrics() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workProcessedCounterMetric.Reset() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+257
to
271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Reset functions: move reconnect reset to client set func ResetSourceCloudEventsMetrics() {
cloudeventsReceivedBySourceCounterMetric.Reset()
cloudeventsSentFromSourceCounterMetric.Reset()
resourceSpecResyncDurationMetric.Reset()
- clientReconnectedCounterMetric.Reset()
}
func ResetClientCloudEventsMetrics() {
cloudeventsReceivedByClientCounterMetric.Reset()
cloudeventsSentFromClientCounterMetric.Reset()
resourceStatusResyncDurationMetric.Reset()
+ clientReconnectedCounterMetric.Reset()
workProcessedCounterMetric.Reset()
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // increaseCloudEventsReceivedCounter increases the cloudevents sent counter metric: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func increaseCloudEventsReceivedCounter(source, cluster, dataType, subresource, action string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // increaseCloudEventsReceivedCounter increases the cloudevents received counter metric: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func increaseCloudEventsReceivedCounter(source, consumer, dataType, subresource, action string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := prometheus.Labels{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel: source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel: cluster, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel: dataType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSubResourceLabel: subresource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsActionLabel: action, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // if it is called by the agent, the consumer is empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if consumer != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels[metricsConsumerLabel] = consumer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cloudeventsReceivedCounterMetric.With(labels).Inc() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // increaseCloudEventsSentCounter increases the cloudevents sent counter metric: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func increaseCloudEventsSentCounter(source, originalSource, cluster, dataType, subresource, action string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func increaseCloudEventsSentCounter(source, originalSource, consumer, dataType, subresource, action string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if originalSource == "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| originalSource = noneOriginalSource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := prometheus.Labels{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel: source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsOriginalSourceLabel: originalSource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel: cluster, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel: dataType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSubResourceLabel: subresource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsActionLabel: action, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // if it is called by the agent, the consumer is empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if consumer != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels[metricsConsumerLabel] = consumer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cloudeventsSentCounterMetric.With(labels).Inc() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // updateResourceSpecResyncDurationMetric updates the resource spec resync duration metric: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func updateResourceSpecResyncDurationMetric(source, cluster, dataType string, startTime time.Time) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func updateResourceSpecResyncDurationMetric(source, consumer, dataType string, startTime time.Time) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := prometheus.Labels{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel: source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel: cluster, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsConsumerLabel: consumer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel: dataType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| duration := time.Since(startTime) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resourceSpecResyncDurationMetric.With(labels).Observe(duration.Seconds()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // updateResourceStatusResyncDurationMetric updates the resource status resync duration metric: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func updateResourceStatusResyncDurationMetric(source, cluster, dataType string, startTime time.Time) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func updateResourceStatusResyncDurationMetric(source, consumer, dataType string, startTime time.Time) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := prometheus.Labels{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsSourceLabel: source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsClusterLabel: cluster, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsConsumerLabel: consumer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsDataTypeLabel: dataType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| duration := time.Since(startTime) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Agent-status resync metrics still carry “consumer” label; remove it to meet PR goal (agent has no cluster/consumer label)
Per PR objective, agent-produced metrics must drop cluster/consumer entirely. Split spec/status label sets so status (agent) has no consumer dimension.
Apply:
func updateResourceStatusResyncDurationMetric(source, consumer, dataType string, startTime time.Time) { labels := prometheus.Labels{ metricsSourceLabel: source, - metricsConsumerLabel: consumer, metricsDataTypeLabel: dataType, } duration := time.Since(startTime) resourceStatusResyncDurationMetric.With(labels).Observe(duration.Seconds()) }Please also update the status-resync doc examples here to drop consumer=… accordingly.
Also applies to: 185-217, 323-331
🤖 Prompt for AI Agents