Class AbstractMetrics<QP extends AbstractMetrics.QueryPhase,​M extends AbstractMetrics.Meter,​G extends AbstractMetrics.Gauge,​T extends AbstractMetrics.Timer>

    • Method Detail

      • addPhaseTiming

        public void addPhaseTiming​(String tableName,
                                   QP phase,
                                   long duration,
                                   TimeUnit timeUnit)
      • addPhaseTiming

        public void addPhaseTiming​(String tableName,
                                   QP phase,
                                   long nanos)
      • addTimedTableValue

        public void addTimedTableValue​(String tableName,
                                       T timer,
                                       long duration,
                                       TimeUnit timeUnit)
        Logs the timing for a table
        Parameters:
        tableName - The table associated with this timer
        timer - The name of timer
        duration - The log time duration time value
        timeUnit - The log time duration time unit
      • addTimedValue

        public void addTimedValue​(T timer,
                                  long duration,
                                  TimeUnit timeUnit)
        Logs the timing for a global timer
      • addMeteredGlobalValue

        public void addMeteredGlobalValue​(M meter,
                                          long unitCount)
        Logs a value to a meter.
        Parameters:
        meter - The meter to use
        unitCount - The number of units to add to the meter
      • addMeteredGlobalValue

        public PinotMeter addMeteredGlobalValue​(M meter,
                                                long unitCount,
                                                PinotMeter reusedMeter)
        Logs a value to a meter.
        Parameters:
        meter - The meter to use
        unitCount - The number of units to add to the meter
        reusedMeter - The meter to reuse
      • addMeteredTableValue

        public void addMeteredTableValue​(String tableName,
                                         M meter,
                                         long unitCount)
        Logs a value to a table-level meter.
        Parameters:
        tableName - The table name
        meter - The meter to use
        unitCount - The number of units to add to the meter
      • addMeteredTableValue

        public PinotMeter addMeteredTableValue​(String tableName,
                                               M meter,
                                               long unitCount,
                                               PinotMeter reusedMeter)
        Logs a value to a table-level meter.
        Parameters:
        tableName - The table name
        meter - The meter to use
        unitCount - The number of units to add to the meter
        reusedMeter - The meter to reuse
      • getMeteredTableValue

        public PinotMeter getMeteredTableValue​(String tableName,
                                               M meter)
      • addValueToTableGauge

        public void addValueToTableGauge​(String tableName,
                                         G gauge,
                                         long unitCount)
        Logs a value to a table gauge.
        Parameters:
        tableName - The table name
        gauge - The gauge to use
        unitCount - The number of units to add to the gauge
      • setValueOfTableGauge

        public void setValueOfTableGauge​(String tableName,
                                         G gauge,
                                         long value)
        Sets the value of a table gauge.
        Parameters:
        tableName - The table name
        gauge - The gauge to use
        value - The value to set the gauge to
      • setValueOfPartitionGauge

        public void setValueOfPartitionGauge​(String tableName,
                                             int partitionId,
                                             G gauge,
                                             long value)
        Sets the value of a table partition gauge.
        Parameters:
        tableName - The table name
        partitionId - The partition name
        gauge - The gauge to use
        value - The value to set the gauge to
      • setValueOfGlobalGauge

        public void setValueOfGlobalGauge​(G gauge,
                                          String suffix,
                                          long value)
        Sets the value of a custom global gauge.
        Parameters:
        suffix - The suffix to attach to the gauge name
        gauge - The gauge to use
        value - The value to set the gauge to
      • setValueOfGlobalGauge

        public void setValueOfGlobalGauge​(G gauge,
                                          long value)
        Sets the value of a global gauge.
        Parameters:
        gauge - The gauge to use
        value - The value to set the gauge to
      • addValueToGlobalGauge

        public void addValueToGlobalGauge​(G gauge,
                                          long unitCount)
        Adds a value to a table gauge.
        Parameters:
        gauge - The gauge to use
        unitCount - The number of units to add to the gauge
      • getValueOfGlobalGauge

        public long getValueOfGlobalGauge​(G gauge)
      • getValueOfGlobalGauge

        public long getValueOfGlobalGauge​(G gauge,
                                          String suffix)
      • getValueOfTableGauge

        public long getValueOfTableGauge​(String tableName,
                                         G gauge)
        Gets the value of a table gauge.
        Parameters:
        tableName - The table name
        gauge - The gauge to use
      • getValueOfPartitionGauge

        public long getValueOfPartitionGauge​(String tableName,
                                             int partitionId,
                                             G gauge)
        Gets the value of a table partition gauge.
        Parameters:
        tableName - The table name
        partitionId - The partition name
        gauge - The gauge to use
      • initializeGlobalMeters

        public void initializeGlobalMeters()
        Initializes all global meters (such as exceptions count) to zero.
      • addCallbackTableGaugeIfNeeded

        public void addCallbackTableGaugeIfNeeded​(String tableName,
                                                  G gauge,
                                                  Callable<Long> valueCallback)
      • addCallbackGaugeIfNeeded

        public void addCallbackGaugeIfNeeded​(String metricName,
                                             Callable<Long> valueCallback)
        Similar to addCallbackGauge method. This method may be called multiple times, while it will be registered to callback function only once.
        Parameters:
        metricName - The name of the metric
        valueCallback - The callback function used to retrieve the value of the gauge
      • addCallbackGauge

        public void addCallbackGauge​(String metricName,
                                     Callable<Long> valueCallback)
        Adds a new gauge whose values are retrieved from a callback function. Once added, the callback function cannot be updated.
        Parameters:
        metricName - The name of the metric
        valueCallback - The callback function used to retrieve the value of the gauge
      • addOrUpdateGauge

        public void addOrUpdateGauge​(String metricName,
                                     Supplier<Long> valueSupplier)
        Adds or updates a gauge whose values are retrieved from the given supplier function. The supplier function can be updated by calling this method again.
        Parameters:
        metricName - The name of the metric
        valueSupplier - The supplier function used to retrieve the value of the gauge
      • removeTableGauge

        public void removeTableGauge​(String tableName,
                                     G gauge)
        Removes a table gauge given the table name and the gauge. The add/remove is expected to work correctly in case of being invoked across multiple threads.
        Parameters:
        tableName - table name
        gauge - the gauge to be removed
      • removeGauge

        public void removeGauge​(String gaugeName)
        Remove gauge from Pinot metrics.
        Parameters:
        gaugeName - gauge name
      • getQueryPhases

        protected abstract QP[] getQueryPhases()
      • getMeters

        protected abstract M[] getMeters()
      • getGauges

        protected abstract G[] getGauges()
      • getTableName

        protected String getTableName​(String tableName)
      • containsGauge

        public boolean containsGauge​(String metricName)
        Check if the metric name appears in the gauge value map.
        Parameters:
        metricName - metric name
        Returns:
        True if the metric name appears on the gauge value map. False otherwise.