gyfora commented on code in PR #312:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/312#discussion_r918673937
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/metrics/OperatorJosdkMetrics.java:
##########
@@ -113,6 +137,19 @@ public void failedReconciliation(ResourceID resourceID,
Exception exception) {
return map;
}
+ private Histogram histogram(String... names) {
+ MetricGroup group = operatorMetricGroup.addGroup(OPERATOR_SDK_GROUP);
+ for (String name : names) {
+ group = group.addGroup(name);
+ }
+ var finalGroup = group;
+ return histograms.computeIfAbsent(
+ String.join(".", group.getScopeComponents()),
+ s ->
+ finalGroup.histogram(
Review Comment:
Instead of `Nanos` I suggest we use Seconds and name it to `TimeSeconds` to
make it consistent with other metrics.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/metrics/OperatorJosdkMetrics.java:
##########
@@ -43,21 +47,41 @@ public class OperatorJosdkMetrics implements Metrics {
private static final String RECONCILIATION = "Reconciliation";
private static final String RESOURCE = "Resource";
private static final String EVENT = "Event";
+ private static final int WINDOW_SIZE = 1000;
private final KubernetesOperatorMetricGroup operatorMetricGroup;
private final Configuration conf;
+ private final Clock clock;
private final Map<ResourceID, KubernetesResourceNamespaceMetricGroup>
resourceNsMetricGroups =
new ConcurrentHashMap<>();
private final Map<ResourceID, KubernetesResourceMetricGroup>
resourceMetricGroups =
new ConcurrentHashMap<>();
+ private final Map<String, Histogram> histograms = new
ConcurrentHashMap<>();
private final Map<String, Counter> counters = new ConcurrentHashMap<>();
public OperatorJosdkMetrics(
KubernetesOperatorMetricGroup operatorMetricGroup, Configuration
conf) {
this.operatorMetricGroup = operatorMetricGroup;
this.conf = conf;
+ this.clock = SystemClock.getInstance();
+ }
+
+ @Override
+ public <T> T timeControllerExecution(ControllerExecution<T> execution)
throws Exception {
+ long startTime = clock.relativeTimeNanos();
+ try {
+ T result = execution.execute();
+ String successType = execution.successTypeName(result);
+ histogram(execution.controllerName(), execution.name(),
successType)
Review Comment:
Instead if using the controllerName directly could we please map this to
`FlinkDeployment` / `FlinkSessionJob` based on the name? This would make it
consistent with other metrics
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]