Class QueryStatManager

java.lang.Object
com.kingsrook.qqq.backend.core.actions.tables.helpers.QueryStatManager

public class QueryStatManager extends Object
Singleton, which starts a thread, to store query stats into a table. Supports these systemProperties or ENV_VARS: qqq.queryStatManager.enabled / QQQ_QUERY_STAT_MANAGER_ENABLED qqq.queryStatManager.minMillisToStore / QQQ_QUERY_STAT_MANAGER_MIN_MILLIS_TO_STORE qqq.queryStatManager.jobPeriodSeconds / QQQ_QUERY_STAT_MANAGER_JOB_PERIOD_SECONDS qqq.queryStatManager.jobInitialDelay / QQQ_QUERY_STAT_MANAGER_JOB_INITIAL_DELAY
  • Method Details

    • getInstance

      public static QueryStatManager getInstance()
      Singleton accessor
    • newQueryStat

      public static QueryStat newQueryStat(QBackendMetaData backend, QTableMetaData table, QQueryFilter filter, String backendActionName)
    • start

      public void start(QInstance qInstance, Supplier<QSession> sessionSupplier)
    • stop

      public void stop()
    • add

      public void add(QueryStat queryStat)
    • storeStatsNow

      public void storeStatsNow()
      force stats to be stored right now (rather than letting the scheduled job do it)
    • getJobPeriodSeconds

      public int getJobPeriodSeconds()
      Getter for jobPeriodSeconds
    • setJobPeriodSeconds

      public void setJobPeriodSeconds(int jobPeriodSeconds)
      Setter for jobPeriodSeconds
    • withJobPeriodSeconds

      public QueryStatManager withJobPeriodSeconds(int jobPeriodSeconds)
      Fluent setter for jobPeriodSeconds
    • getJobInitialDelay

      public int getJobInitialDelay()
      Getter for jobInitialDelay
    • setJobInitialDelay

      public void setJobInitialDelay(int jobInitialDelay)
      Setter for jobInitialDelay
    • withJobInitialDelay

      public QueryStatManager withJobInitialDelay(int jobInitialDelay)
      Fluent setter for jobInitialDelay
    • getMinMillisToStore

      public int getMinMillisToStore()
      Getter for minMillisToStore
    • setMinMillisToStore

      public void setMinMillisToStore(int minMillisToStore)
      Setter for minMillisToStore
    • withMinMillisToStore

      public QueryStatManager withMinMillisToStore(int minMillisToStore)
      Fluent setter for minMillisToStore
    • getQueryStatConsumers

      public List<QueryStatConsumerInterface> getQueryStatConsumers()
      Getter for queryStatConsumers
      See Also:
    • setQueryStatConsumers

      public void setQueryStatConsumers(List<QueryStatConsumerInterface> queryStatConsumers)
      Setter for queryStatConsumers
      See Also:
    • withQueryStatConsumers

      public QueryStatManager withQueryStatConsumers(List<QueryStatConsumerInterface> queryStatConsumers)
      Fluent setter for queryStatConsumers
      Parameters:
      queryStatConsumers - List of instances of QueryStateConsumerInterface - e.g., classes that want to be invoked when a query stat object is being added to the manager here (e.g., after its query is complete).
      Returns:
      this
    • addQueryStatConsumer

      public void addQueryStatConsumer(QueryStatConsumerInterface queryStatConsumer)
      add one query stat consumer to the list.
      See Also:
    • getEmptyActionStackLogLevel

      public org.apache.logging.log4j.Level getEmptyActionStackLogLevel()
      Getter for emptyActionStackLogLevel
      See Also:
    • setEmptyActionStackLogLevel

      public void setEmptyActionStackLogLevel(org.apache.logging.log4j.Level emptyActionStackLogLevel)
      Setter for emptyActionStackLogLevel
      See Also:
    • withEmptyActionStackLogLevel

      public QueryStatManager withEmptyActionStackLogLevel(org.apache.logging.log4j.Level emptyActionStackLogLevel)
      Fluent setter for emptyActionStackLogLevel
      Parameters:
      emptyActionStackLogLevel - log level to use to log out if there's ever a query stat being recorded when the actionStack in QContext is empty.

      Originally that was thought to be an unexpected condition, so it used to always warn. but, it turns out to be more common maybe, and not necessarily of any concern, so the default level is OFF - but it can be upgraded by setting this property.

      Returns:
      this