X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fcommon%2Factor%2FMeteringBehavior.java;h=c04e2e93402ad12915828812d4365016fabbda51;hb=412db94945c5db5d2da918f5e23bd3abcecc4d10;hp=d67d413d0963fff464503391002a3e6d3af15bee;hpb=b5b204bafd8ee18692fc023cb2eae6e123369340;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java index d67d413d09..c04e2e9340 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/MeteringBehavior.java @@ -26,25 +26,42 @@ import org.opendaylight.controller.cluster.reporting.MetricsReporter; * The information is reported to {@link org.opendaylight.controller.cluster.reporting.MetricsReporter} */ public class MeteringBehavior implements Procedure { + public static final String DOMAIN = "org.opendaylight.controller.actor.metric"; private final UntypedActor meteredActor; - private final MetricRegistry METRICREGISTRY = MetricsReporter.getInstance().getMetricsRegistry(); + private final MetricRegistry METRICREGISTRY = MetricsReporter.getInstance(DOMAIN).getMetricsRegistry(); private final String MSG_PROCESSING_RATE = "msg-rate"; - private String actorName; + private String actorQualifiedName; private Timer msgProcessingTimer; /** * * @param actor whose behaviour needs to be metered */ - public MeteringBehavior(UntypedActor actor){ + public MeteringBehavior(AbstractUntypedActorWithMetering actor){ Preconditions.checkArgument(actor != null, "actor must not be null"); + this.meteredActor = actor; + String actorName = actor.getActorNameOverride() != null ? actor.getActorNameOverride() + : actor.getSelf().path().name(); + init(actorName); + } + + public MeteringBehavior(UntypedActor actor){ + Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; - actorName = meteredActor.getSelf().path().toStringWithoutAddress(); - final String msgProcessingTime = MetricRegistry.name(actorName, MSG_PROCESSING_RATE); + + String actorName = actor.getSelf().path().name(); + init(actorName); + } + + private void init(String actorName){ + actorQualifiedName = new StringBuilder(meteredActor.getSelf().path().parent().toStringWithoutAddress()). + append("/").append(actorName).toString(); + + final String msgProcessingTime = MetricRegistry.name(actorQualifiedName, MSG_PROCESSING_RATE); msgProcessingTimer = METRICREGISTRY.timer(msgProcessingTime); } @@ -69,7 +86,7 @@ public class MeteringBehavior implements Procedure { final String messageType = message.getClass().getSimpleName(); final String msgProcessingTimeByMsgType = - MetricRegistry.name(actorName, MSG_PROCESSING_RATE, messageType); + MetricRegistry.name(actorQualifiedName, MSG_PROCESSING_RATE, messageType); final Timer msgProcessingTimerByMsgType = METRICREGISTRY.timer(msgProcessingTimeByMsgType);