Skip to content

Commit

Permalink
Add query count per session metric (opensearch-project#890)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoyuki Morita <[email protected]>
Signed-off-by: Tomoyuki MORITA <[email protected]>
  • Loading branch information
ykmr1224 authored and 14yapkc1 committed Dec 11, 2024
1 parent efa0008 commit 39a1e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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 @@ -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

0 comments on commit 39a1e9d

Please sign in to comment.