Skip to content

Commit 98b260a

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 87fd299 commit 98b260a

File tree

11 files changed

+119
-435
lines changed

11 files changed

+119
-435
lines changed

micrometer-support/src/main/java/io/javaoperatorsdk/operator/monitoring/micrometer/MicrometerMetrics.java

Lines changed: 33 additions & 169 deletions
Large diffs are not rendered by default.

micrometer-support/src/test/java/io/javaoperatorsdk/operator/monitoring/micrometer/AbstractMicrometerMetricsTestFixture.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import io.micrometer.core.instrument.Meter;
3131
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
3232

33-
import static org.assertj.core.api.Assertions.assertThat;
3433
import static org.awaitility.Awaitility.await;
3534

3635
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@@ -66,28 +65,12 @@ void properlyHandlesResourceDeletion() throws Exception {
6665
.isEmpty());
6766

6867
final var resourceID = ResourceID.fromResource(created);
69-
final var meters = preDeleteChecks(resourceID);
7068

7169
// delete the resource and wait for it to be deleted
7270
operator.delete(testResource);
7371
await().until(() -> operator.get(ConfigMap.class, testResourceName) == null);
74-
75-
postDeleteChecks(resourceID, meters);
76-
}
77-
78-
protected Set<Meter.Id> preDeleteChecks(ResourceID resourceID) {
79-
// check that we properly recorded meters associated with the resource
80-
final var meters = metrics.recordedMeterIdsFor(resourceID);
81-
// metrics are collected per resource
82-
assertThat(registry.getMetersAsString()).contains(resourceID.getName());
83-
assertThat(meters).isNotNull();
84-
assertThat(meters).isNotEmpty();
85-
return meters;
8672
}
8773

88-
protected void postDeleteChecks(ResourceID resourceID, Set<Meter.Id> recordedMeters)
89-
throws Exception {}
90-
9174
@ControllerConfiguration
9275
private static class MetricsCleaningTestReconciler
9376
implements Reconciler<ConfigMap>, Cleaner<ConfigMap> {

micrometer-support/src/test/java/io/javaoperatorsdk/operator/monitoring/micrometer/DefaultBehaviorIT.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,9 @@
1515
*/
1616
package io.javaoperatorsdk.operator.monitoring.micrometer;
1717

18-
import java.util.Collections;
19-
import java.util.Set;
20-
21-
import io.javaoperatorsdk.operator.processing.event.ResourceID;
22-
import io.micrometer.core.instrument.Meter;
23-
24-
import static org.assertj.core.api.Assertions.assertThat;
25-
2618
public class DefaultBehaviorIT extends AbstractMicrometerMetricsTestFixture {
2719
@Override
2820
protected MicrometerMetrics getMetrics() {
2921
return MicrometerMetrics.newMicrometerMetricsBuilder(registry).build();
3022
}
31-
32-
@Override
33-
protected Set<Meter.Id> preDeleteChecks(ResourceID resourceID) {
34-
// no meter should be recorded because we're not tracking anything to be deleted later
35-
assertThat(metrics.recordedMeterIdsFor(resourceID)).isEmpty();
36-
// metrics are collected per resource by default for now, this will change in a future release
37-
assertThat(registry.getMetersAsString()).contains(resourceID.getName());
38-
return Collections.emptySet();
39-
}
40-
41-
@Override
42-
protected void postDeleteChecks(ResourceID resourceID, Set<Meter.Id> recordedMeters) {
43-
// meters should be neither recorded, nor removed by default
44-
assertThat(registry.getRemoved()).isEmpty();
45-
}
4623
}

micrometer-support/src/test/java/io/javaoperatorsdk/operator/monitoring/micrometer/DelayedMetricsCleaningOnDeleteIT.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

micrometer-support/src/test/java/io/javaoperatorsdk/operator/monitoring/micrometer/NoPerResourceCollectionIT.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,9 @@
1515
*/
1616
package io.javaoperatorsdk.operator.monitoring.micrometer;
1717

18-
import java.util.Collections;
19-
import java.util.Set;
20-
21-
import io.javaoperatorsdk.operator.processing.event.ResourceID;
22-
import io.micrometer.core.instrument.Meter;
23-
24-
import static org.assertj.core.api.Assertions.assertThat;
25-
2618
public class NoPerResourceCollectionIT extends AbstractMicrometerMetricsTestFixture {
2719
@Override
2820
protected MicrometerMetrics getMetrics() {
2921
return MicrometerMetrics.withoutPerResourceMetrics(registry);
3022
}
31-
32-
@Override
33-
protected Set<Meter.Id> preDeleteChecks(ResourceID resourceID) {
34-
assertThat(metrics.recordedMeterIdsFor(resourceID)).isEmpty();
35-
assertThat(registry.getMetersAsString()).doesNotContain(resourceID.getName());
36-
return Collections.emptySet();
37-
}
3823
}

observability/josdk-operator-metrics-dashboard.json

Lines changed: 10 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@
369369
"uid": "prometheus"
370370
},
371371
"editorMode": "code",
372-
"expr": "sum(operator_sdk_reconciliations_queue_size{service_name=\"josdk\"})",
373-
"legendFormat": "Queue Size",
372+
"expr": "sum(operator_sdk_reconciliations_active{service_name=\"josdk\"})",
373+
"legendFormat": "Active",
374374
"range": true,
375375
"refId": "A"
376376
}
377377
],
378-
"title": "Reconciliation Queue Size",
378+
"title": "Active Reconciliations",
379379
"type": "gauge"
380380
},
381381
{
@@ -585,7 +585,7 @@
585585
"uid": "prometheus"
586586
},
587587
"editorMode": "code",
588-
"expr": "histogram_quantile(0.50, sum(rate(operator_sdk_controllers_execution_reconcile_seconds_bucket{service_name=\"josdk\"}[5m])) by (le, controller))",
588+
"expr": "histogram_quantile(0.50, sum(rate(operator_sdk_reconciliations_execution_duration_seconds_bucket{service_name=\"josdk\"}[5m])) by (le, controller))",
589589
"legendFormat": "p50 - {{controller}}",
590590
"range": true,
591591
"refId": "A"
@@ -596,7 +596,7 @@
596596
"uid": "prometheus"
597597
},
598598
"editorMode": "code",
599-
"expr": "histogram_quantile(0.95, sum(rate(operator_sdk_controllers_execution_reconcile_seconds_bucket{service_name=\"josdk\"}[5m])) by (le, controller))",
599+
"expr": "histogram_quantile(0.95, sum(rate(operator_sdk_reconciliations_execution_duration_seconds_bucket{service_name=\"josdk\"}[5m])) by (le, controller))",
600600
"legendFormat": "p95 - {{controller}}",
601601
"range": true,
602602
"refId": "B"
@@ -607,7 +607,7 @@
607607
"uid": "prometheus"
608608
},
609609
"editorMode": "code",
610-
"expr": "histogram_quantile(0.99, sum(rate(operator_sdk_controllers_execution_reconcile_seconds_bucket{service_name=\"josdk\"}[5m])) by (le, controller))",
610+
"expr": "histogram_quantile(0.99, sum(rate(operator_sdk_reconciliations_execution_duration_seconds_bucket{service_name=\"josdk\"}[5m])) by (le, controller))",
611611
"legendFormat": "p99 - {{controller}}",
612612
"range": true,
613613
"refId": "C"
@@ -877,8 +877,8 @@
877877
"uid": "prometheus"
878878
},
879879
"editorMode": "code",
880-
"expr": "sum(rate(operator_sdk_controllers_execution_reconcile_success_total{service_name=\"josdk\"}[5m])) by (type)",
881-
"legendFormat": "Success - {{type}}",
880+
"expr": "sum(rate(operator_sdk_controllers_success_total{service_name=\"josdk\"}[5m])) by (controller)",
881+
"legendFormat": "Success - {{controller}}",
882882
"range": true,
883883
"refId": "A"
884884
},
@@ -888,8 +888,8 @@
888888
"uid": "prometheus"
889889
},
890890
"editorMode": "code",
891-
"expr": "sum(rate(operator_sdk_controllers_execution_reconcile_failure_total{service_name=\"josdk\"}[5m])) by (exception)",
892-
"legendFormat": "Failure - {{exception}}",
891+
"expr": "sum(rate(operator_sdk_controllers_failure_total{service_name=\"josdk\"}[5m])) by (controller)",
892+
"legendFormat": "Failure - {{controller}}",
893893
"range": true,
894894
"refId": "B"
895895
}
@@ -1084,112 +1084,6 @@
10841084
],
10851085
"title": "Reconciliation Retry Attempts",
10861086
"type": "timeseries"
1087-
},
1088-
{
1089-
"datasource": {
1090-
"type": "prometheus",
1091-
"uid": "prometheus"
1092-
},
1093-
"description": "Resources currently on their last retry attempt (1 = last attempt, 0 = not last or no retry)",
1094-
"fieldConfig": {
1095-
"defaults": {
1096-
"color": {
1097-
"mode": "palette-classic"
1098-
},
1099-
"custom": {
1100-
"axisCenteredZero": false,
1101-
"axisColorMode": "text",
1102-
"axisLabel": "",
1103-
"axisPlacement": "auto",
1104-
"barAlignment": 0,
1105-
"drawStyle": "line",
1106-
"fillOpacity": 10,
1107-
"gradientMode": "none",
1108-
"hideFrom": {
1109-
"tooltip": false,
1110-
"viz": false,
1111-
"legend": false
1112-
},
1113-
"lineInterpolation": "stepAfter",
1114-
"lineWidth": 1,
1115-
"pointSize": 5,
1116-
"scaleDistribution": {
1117-
"type": "linear"
1118-
},
1119-
"showPoints": "auto",
1120-
"spanNulls": false,
1121-
"stacking": {
1122-
"group": "A",
1123-
"mode": "none"
1124-
},
1125-
"thresholdsStyle": {
1126-
"mode": "off"
1127-
}
1128-
},
1129-
"mappings": [
1130-
{
1131-
"options": {
1132-
"0": {
1133-
"text": "No"
1134-
},
1135-
"1": {
1136-
"text": "Yes"
1137-
}
1138-
},
1139-
"type": "value"
1140-
}
1141-
],
1142-
"thresholds": {
1143-
"mode": "absolute",
1144-
"steps": [
1145-
{
1146-
"color": "green",
1147-
"value": null
1148-
},
1149-
{
1150-
"color": "red",
1151-
"value": 1
1152-
}
1153-
]
1154-
},
1155-
"unit": "short"
1156-
},
1157-
"overrides": []
1158-
},
1159-
"gridPos": {
1160-
"h": 8,
1161-
"w": 12,
1162-
"x": 0,
1163-
"y": 40
1164-
},
1165-
"id": 13,
1166-
"options": {
1167-
"legend": {
1168-
"calcs": ["last"],
1169-
"displayMode": "table",
1170-
"placement": "bottom",
1171-
"showLegend": true
1172-
},
1173-
"tooltip": {
1174-
"mode": "single",
1175-
"sort": "none"
1176-
}
1177-
},
1178-
"targets": [
1179-
{
1180-
"datasource": {
1181-
"type": "prometheus",
1182-
"uid": "prometheus"
1183-
},
1184-
"editorMode": "code",
1185-
"expr": "operator_sdk_reconciliations_retries_last{service_name=\"josdk\"}",
1186-
"legendFormat": "{{kind}}/{{name}} ({{namespace}})",
1187-
"range": true,
1188-
"refId": "A"
1189-
}
1190-
],
1191-
"title": "Resources on Last Retry Attempt",
1192-
"type": "timeseries"
11931087
}
11941088
],
11951089
"refresh": "10s",

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/monitoring/Metrics.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,6 @@ interface ControllerExecution<T> {
125125
*/
126126
String controllerName();
127127

128-
/**
129-
* Retrieves the name of the successful result when the reconciliation ended positively.
130-
* Possible values comes from the different outcomes provided by {@link
131-
* io.javaoperatorsdk.operator.api.reconciler.UpdateControl} or {@link
132-
* io.javaoperatorsdk.operator.api.reconciler.DeleteControl}.
133-
*
134-
* @param result the reconciliation result
135-
* @return a name associated with the specified outcome
136-
*/
137-
String successTypeName(T result);
138-
139128
/**
140129
* Retrieves the {@link ResourceID} of the resource associated with the controller execution
141130
* being considered

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/Controller.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ public class Controller<P extends HasMetadata>
7070

7171
private static final Logger log = LoggerFactory.getLogger(Controller.class);
7272
private static final String CLEANUP = "cleanup";
73-
private static final String DELETE = "delete";
74-
private static final String FINALIZER_NOT_REMOVED = "finalizerNotRemoved";
7573
private static final String RECONCILE = "reconcile";
76-
private static final String RESOURCE = "resource";
77-
private static final String STATUS = "status";
78-
private static final String BOTH = "both";
7974
public static final String CLEANER_NOT_SUPPORTED_ON_ALL_EVENT_ERROR_MESSAGE =
8075
"Cleaner is not supported when triggerReconcilerOnAllEvents enabled.";
8176
public static final String
@@ -155,18 +150,6 @@ public String controllerName() {
155150
return configuration.getName();
156151
}
157152

158-
@Override
159-
public String successTypeName(UpdateControl<P> result) {
160-
String successType = RESOURCE;
161-
if (result.isPatchStatus()) {
162-
successType = STATUS;
163-
}
164-
if (result.isPatchResourceAndStatus()) {
165-
successType = BOTH;
166-
}
167-
return successType;
168-
}
169-
170153
@Override
171154
public ResourceID resourceID() {
172155
return ResourceID.fromResource(resource);
@@ -208,11 +191,6 @@ public String controllerName() {
208191
return configuration.getName();
209192
}
210193

211-
@Override
212-
public String successTypeName(DeleteControl deleteControl) {
213-
return deleteControl.isRemoveFinalizer() ? DELETE : FINALIZER_NOT_REMOVED;
214-
}
215-
216194
@Override
217195
public ResourceID resourceID() {
218196
return ResourceID.fromResource(resource);

0 commit comments

Comments
 (0)