Github user tillrohrmann commented on a diff in the pull request: https://github.com/apache/flink/pull/2363#discussion_r77527444 --- Diff: flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/metrics/MetricStore.java --- @@ -35,109 +46,111 @@ final Map<String, TaskManagerMetricStore> taskManagers = new HashMap<>(); final Map<String, JobMetricStore> jobs = new HashMap<>(); - /** - * Adds a metric to this MetricStore. - * - * @param name the metric identifier - * @param value the metric value - */ - public void add(String name, Object value) { - TaskManagerMetricStore tm; - JobMetricStore job; - TaskMetricStore task; - + public void add(MetricDump metric) { try { - String[] components = name.split(":"); - switch (components[0]) { - /** - * JobManagerMetricStore metric - * format: 0:<user_scope>.<name> - */ - case "0": - jobManager.metrics.put(components[1], value); - break; - /** - * TaskManager metric - * format: 1:<tm_id>:<user_scope>.<name> - */ - case "1": - if (components.length != 3) { - break; - } - tm = taskManagers.get(components[1]); + QueryScopeInfo info = metric.scopeInfo; + TaskManagerMetricStore tm; + JobMetricStore job; + TaskMetricStore task; + + String name = info.scope.isEmpty() + ? metric.name + : info.scope + "." + metric.name; + + if (name.isEmpty()) { // malformed transmission + return; + } + + switch (info.getCategory()) { + case INFO_CATEGORY_JM: --- End diff -- What's the benefit of having an explicit type field over using `instanceof`? I think encoding the type via the actual type has the advantage that you don't mix up classes with wrong category types.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---