Vyacheslav Koptilin created IGNITE-26703:
--------------------------------------------

             Summary: MetricRegistry should allow registering already enabled 
metric sources
                 Key: IGNITE-26703
                 URL: https://issues.apache.org/jira/browse/IGNITE-26703
             Project: Ignite
          Issue Type: Improvement
    Affects Versions: 3.0, 3.1
            Reporter: Vyacheslav Koptilin


Currently, `MetricRegistry` does not allow registering already enabled metric 
sources:
{code:java}
public void registerSource(MetricSource src) {
    lock.lock();

    try {
        // Metric source shouldn't be enabled before because the second call of 
MetricSource#enable will return null.
        assert !src.enabled() : "Metric source shouldn't be enabled before 
registration in registry.";

        MetricSource old = sources.putIfAbsent(src.name(), src);

        if (old != null) {
            throw new IllegalStateException("Metrics source with given name 
already exists: " + src.name());
        }
    } finally {
        lock.unlock();
    }
} {code}
At first, we need to understand why this limitation was introduced, of course.

IMHO, the limitation does not allow `replacing` a metric source in a light way.
For instance, let's assume that we have a table and the corresponding metric 
source is enabled. When the table is renamed, we need to unregister the 
previous metric source, create a new one with the same metric set (to retain 
metric values and preserve the history), and register the latest source. 
Unfortunately, in that case, the new source is considered an enabled one and 
cannot be registered.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to