*/
public abstract class AbstractUntypedActorWithMetering extends AbstractUntypedActor {
+ //this is used in the metric name. Some transient actors do not have defined names
+ private String actorNameOverride;
+
public AbstractUntypedActorWithMetering() {
if (isMetricsCaptureEnabled())
getContext().become(new MeteringBehavior(this));
}
+ public AbstractUntypedActorWithMetering(String actorNameOverride){
+ this.actorNameOverride = actorNameOverride;
+ if (isMetricsCaptureEnabled())
+ getContext().become(new MeteringBehavior(this));
+ }
+
private boolean isMetricsCaptureEnabled(){
CommonConfig config = new CommonConfig(getContext().system().settings().config());
return config.isMetricCaptureEnabled();
}
+
+ public String getActorNameOverride() {
+ return actorNameOverride;
+ }
}
private final MetricRegistry METRICREGISTRY = MetricsReporter.getInstance().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);
}
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);
import akka.japi.Creator;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
+import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActorWithMetering;
import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
* <li> {@link org.opendaylight.controller.cluster.datastore.messages.CloseTransaction}
* </p>
*/
-public abstract class ShardTransaction extends AbstractUntypedActor {
+public abstract class ShardTransaction extends AbstractUntypedActorWithMetering {
private final ActorRef shardActor;
private final SchemaContext schemaContext;
protected ShardTransaction(ActorRef shardActor, SchemaContext schemaContext,
ShardStats shardStats, String transactionID) {
+ super("shard-tx"); //actor name override used for metering. This does not change the "real" actor name
this.shardActor = shardActor;
this.schemaContext = schemaContext;
this.shardStats = shardStats;