opensearch-project / performance-analyzer-commons

Apache License 2.0
4 stars 18 forks source link

[FEATURE] Add Inherent support for service metrics in Collector Framework #8

Closed khushbr closed 1 year ago

khushbr commented 1 year ago

Is your feature request related to a problem? Instead of relying on Individual Collector in PA-RCA, emit Service metrics(Latency, Exceptions and Errors) centrally within the Framework. This will ensure all the collectors have execution time metrics present. This can be achieved re-factoring the PerformanceAnalyzerMetricsCollector Base class to add new collectMetricsAndLog() method:

    public void collectMetricsAndLog(long startTime, MeasurementSet timeMetric, MeasurementSet errorMetric) {
        try {
            long mCurrT = System.currentTimeMillis();
            collectMetrics();
            PerformanceAnalyzerApp.WRITER_METRICS_AGGREGATOR.updateStat(
                    timeMetric, "", System.currentTimeMillis() - mCurrT);
        } catch (Exception ex) {
            LOG.debug(
                    "Exception in Collecting {} Metrics: {} for startTime {}",
                    this.getCollectorName(),
                    () -> ex.toString(),
                    () -> startTime);
            PerformanceAnalyzerApp.ERRORS_AND_EXCEPTIONS_AGGREGATOR.updateStat(
                    errorMetric, "", 1);
        }
    }
khushbr commented 1 year ago

Release done for PA-Commons 1.0.0 - https://github.com/opensearch-project/performance-analyzer-commons/releases/tag/1.0.0