dcapwell commented on code in PR #2534: URL: https://github.com/apache/cassandra/pull/2534#discussion_r1316434929
########## src/java/org/apache/cassandra/metrics/AccordMetrics.java: ########## @@ -0,0 +1,279 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.metrics; + +import java.lang.reflect.Field; +import java.util.concurrent.TimeUnit; + +import accord.api.EventsListener; +import accord.local.Command; +import accord.primitives.Deps; +import accord.primitives.PartialDeps; +import accord.primitives.Timestamp; +import accord.primitives.TxnId; +import com.codahale.metrics.Counting; +import com.codahale.metrics.Histogram; +import com.codahale.metrics.Meter; +import com.codahale.metrics.Timer; +import org.apache.cassandra.service.accord.AccordService; + +import static java.util.concurrent.TimeUnit.MICROSECONDS; +import static org.apache.cassandra.metrics.CassandraMetricsRegistry.Metrics; + +public class AccordMetrics +{ + public final static AccordMetrics readMetrics = new AccordMetrics("ro"); + public final static AccordMetrics writeMetrics = new AccordMetrics("rw"); + + /** + * The time between start on the coordinator and commit on this replica. + */ + public final Timer commitLatency; + + /** + * The time between start on the coordinator and execution on this replica. + */ + public final Timer executeLatency; + + /** + * The time between start on the coordinator and application on this replica. + */ + public final Timer applyLatency; + + /** + * Duration of applying changes. + */ + public final Timer applyDuration; + + /** + * The number of dependencies of the transaction on this replica. + */ + public final Histogram deps; + + public final Meter progressLogSize; + + /** + * The number of dependencies of the transaction. + */ + public final Histogram coordinatorDeps; + + /** + * The number of fast path transactions executed on this coordinator. + */ + public final Meter coordinatorFastPathTrx; + + /** + * The number of slow path transactions executed on this coordinator. + */ + public final Meter coordinatorSlowPathTrx; + + /** + * The number of preempted transactions on this coordinator. + */ + public final Meter coordinatorPreemptedTrx; + + /** + * The number of timed out transactions on this coordinator. + */ + public final Meter coordinatorTimedoutTrx; Review Comment: > What about the events at the recovery coordinator? This gets tricky as every node will try to recover from time to time, and it won't know if it actually did anything in some cases[1]. We also get into the situation where multi key txn runs and could double count as we see the events in multiple `CommandStore`, so not sure how you would handle dedup in these cases (or do we just double count?). I would need to look at this patch, but even having metrics in `Recover` is tricky as our callback doesn't mean we recovered, only that we scheduled things[1]... The `TransactionStatement` is simple as its logically contained, but that isn't true with recover, so we would need to be careful... Now, I guess my main question is "how would an operator use these metrics"? If the answer is "I don't know" then prob best to punt or try to flesh that out. [1] `accord.coordinate.Recover#recover()` ``` Deps committedDeps = tryMergeCommittedDeps(); node.withEpoch(executeAt.epoch(), () -> { // TODO (required, consider): when writes/result are partially replicated, need to confirm we have quorum of these if (committedDeps != null) Persist.persistMaximal(node, txnId, route, txn, executeAt, committedDeps, acceptOrCommit.writes, acceptOrCommit.result); else CollectDeps.withDeps(node, txnId, route, txn.keys(), executeAt, (deps, fail) -> { if (fail != null) accept(null, fail); else Persist.persistMaximal(node, txnId, route, txn, executeAt, deps, acceptOrCommit.writes, acceptOrCommit.result); }); }); accept(acceptOrCommit.result, null); ``` Here we trigger the callback saying success, but later on it might actually fail, which will then require another repair to try to push things along... -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

