kgusakov commented on code in PR #1098:
URL: https://github.com/apache/ignite-3/pull/1098#discussion_r980359468


##########
modules/metrics/src/main/java/org/apache/ignite/internal/metrics/MetricManager.java:
##########
@@ -33,38 +42,61 @@
  * Metric manager.
  */
 public class MetricManager implements IgniteComponent {
+
+    /** Logger. */
+    private static final IgniteLogger LOG = 
Loggers.forClass(MetricManager.class);
+
     /**
      * Metric registry.
      */
     private final MetricRegistry registry;
 
+    private final MetricProvider metricsProvider;
+
+    private final Map<String, MetricExporter> enabledMetricExporters = new 
HashMap<>();
+
     /** Metrics' exporters. */
-    private List<MetricExporter> metricExporters;
+    private Map<String, MetricExporter> availableExporters;
+
+    private MetricConfiguration metricConfiguration;
 
     /**
      * Constructor.
      */
     public MetricManager() {
-        this.registry = new MetricRegistry();
+        registry = new MetricRegistry();
+        metricsProvider = new MetricProvider(registry);
+    }
+
+    /**
+     * Method to configure {@link MetricManager} with distributed 
configuration.
+     *
+     * @param metricConfiguration Distributed metric configuration.
+     */
+    // TODO: IGNITE-17718 when we design the system to configure metrics itself
+    // TODO: this method should be revisited, but now it is supposed to use 
only to set distributed configuration for exporters.
+    public void configure(MetricConfiguration metricConfiguration) {
+        assert this.metricConfiguration == null : "Metric manager must be 
configured only once, on the start of the node";
+
+        this.metricConfiguration = metricConfiguration;
     }
 
     /** {@inheritDoc} */
     @Override public void start() {
-        // TODO: IGNITE-17358 not all exporters should be started, it must be 
defined by configuration
-        metricExporters = loadExporters();
+        availableExporters = loadExporters();
 
-        MetricProvider metricsProvider = new MetricProvider(registry);
+        MetricView conf = metricConfiguration.value();
 
-        for (MetricExporter metricExporter : metricExporters) {
-            metricExporter.init(metricsProvider);
-
-            metricExporter.start();
+        for (String exporterName : conf.exporters().namedListKeys()) {
+            checkAndStartExporter(exporterName, 
metricConfiguration.exporters().get(exporterName));
         }
+
+        metricConfiguration.exporters().listenElements(new 
ExporterConfigurationListeter());

Review Comment:
   ```suggestion
           metricConfiguration.exporters().listenElements(new 
ExporterConfigurationListener());
   ```



-- 
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]

Reply via email to