Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query count per session metric #890

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public final class MetricConstants {
*/
public static final String REPL_PROCESSING_TIME_METRIC = "session.processingTime";

/**
* Metric name for counting the number of queries executed per session.
*/
public static final String REPL_QUERY_COUNT_METRIC = "session.query.count";

/**
* Prefix for metrics related to the request metadata read operations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.codahale.metrics.Timer
import org.opensearch.flint.common.model.{FlintStatement, InteractiveSession, SessionStates}
import org.opensearch.flint.core.FlintOptions
import org.opensearch.flint.core.logging.CustomLogging
import org.opensearch.flint.core.metrics.{MetricConstants, ReadWriteBytesSparkListener}
import org.opensearch.flint.core.metrics.{MetricConstants, MetricsUtil, ReadWriteBytesSparkListener}
import org.opensearch.flint.core.metrics.MetricsUtil.{getTimerContext, incrementCounter, registerGauge, stopTimer}

import org.apache.spark.SparkConf
Expand Down Expand Up @@ -57,6 +57,7 @@ object FlintREPL extends Logging with FlintJobExecutor {

private val sessionRunningCount = new AtomicInteger(0)
private val statementRunningCount = new AtomicInteger(0)
private var queryCountMetric = 0

def main(args: Array[String]) {
val (queryOption, resultIndexOption) = parseArgs(args)
Expand Down Expand Up @@ -365,6 +366,7 @@ object FlintREPL extends Logging with FlintJobExecutor {
if (threadPool != null) {
threadPoolFactory.shutdownThreadPool(threadPool)
}
MetricsUtil.addHistoricGauge(MetricConstants.REPL_QUERY_COUNT_METRIC, queryCountMetric)
}
}

Expand Down Expand Up @@ -521,6 +523,7 @@ object FlintREPL extends Logging with FlintJobExecutor {
flintStatement.running()
statementExecutionManager.updateStatement(flintStatement)
statementRunningCount.incrementAndGet()
queryCountMetric += 1

val statementTimerContext = getTimerContext(
MetricConstants.STATEMENT_PROCESSING_TIME_METRIC)
Expand Down
Loading