[ 
https://issues.apache.org/jira/browse/IGNITE-11927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16898076#comment-16898076
 ] 

Andrey Gura edited comment on IGNITE-11927 at 8/1/19 1:13 PM:
--------------------------------------------------------------

[~NIzhikov] Not certainly in that way. WE don't need NO_OP_METRIC concept 
because we don't disable metric itself, we disable whole set of metrics that is 
represented by metric registry. So metric registry also should be removed. 
Moreover, holder itself can contain logic related with change if metric state. 
It should look like:

{code:java}
class MetricHolder {
  boolean enabled;

  AtomicLongMetric m;

  public MetricHolder(GirdKernalContext ctx) {
    ctx.monitoring.onDisable("metrics", () -> {
              ctx.metric().remove("registryName");

              m = null;              
         }
    );

    ctx.monitoring.onEnable("metrics", r -> {
          MetricRegistry r = new MetricRegistry("registryName");

          m = r.longMetric("metric");

          ctx.metric().add("registryName");
         }
    );
  }

  public long m() {
    assert enabled;

    return m;
  }

  public void changeState() {
    if (enabled)
      m().increment();
  }
}

class SomeProcessor {
  public SomeProcesor() {
    metricHolder = new MetricHolder(ctx);
  }
}
{code}


was (Author: agura):
[~NIzhikov] Not certainly in that way. WE don't need NO_OP_METRIC concept 
because we don't disable metric itself, we disable whole set of metrics that is 
represented by metric registry. So metric registry also should be removed. 
Moreover, holder itself can contain logic related with change if metric state. 
It should look like:

{code:java}
class MetricHolder {
  boolean enabled;

  AtomicLongMetric m;

  public MetricHolder(GirdKernalContext ctx) {
    ctx.monitoring.onDisable("metrics", () -> {
              ctx.metric().remove("registryName");

              m = null;              
         }
    );

    ctx.monitoring.onEnable("metrics", r -> {
          MetricRegistry r = new MetricRegistry("registryName");

          m = r.longMetric("metric");

          ctx.metric().add("registryName");
         }
    );
  }

  public long m() {
    assert enabled;

    return m;
  }

  public void changeState() {
    if (enabled)
      m().increment();
  }
}

class SomeProcessor {
  public SomeProcesor() {
    metricHolder = new MetricHolder(ctx);
  }
}
{java}

> [IEP-35] Add ability to enable\disable subset of metrics
> --------------------------------------------------------
>
>                 Key: IGNITE-11927
>                 URL: https://issues.apache.org/jira/browse/IGNITE-11927
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Nikolay Izhikov
>            Assignee: Nikolay Izhikov
>            Priority: Major
>              Labels: IEP-35
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Ignite should be able to:
> * Enable or disable an arbitrary subset of the metrics. User should be able 
> to do it in runtime.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to