In src/main/java/org/opensearch/performanceanalyzer/commons
:
-
Classes in
hwnet
,jvm
andos
collect metrics by interfacing with external systems (the OS or Java). -
Classes in
metrics_generator/linux
wrap over collection logic and store results inMap
s that are refreshed whenaddSample
is called. -
Classes in
metrics_generator
contain interfaces to abstract over classes inmetrics_generator/linux
. -
Classes in
collectors
- suffixed by
Metrics
orSummary
extendMetricStatus
. These classes describe one measurement. For example,DiskMetrics
contains the name, utilization, service rate, etc. - suffixed by
Collector
extendPerformanceAnalyzerMetricsCollector
and implementMetricsProcessor
.PerformanceAnalyzerMetricsCollector
implementsRunnable
and contains common variables likevalue
where a collector stores serialized metrics.- A collector is triggered through
PerformanceAnalyzerMetricsCollector.collectMetrics
.- The collector will store serialized data in the
value
variable and then callMetricsProcessor.saveMetricValues
. saveMetricValues
callsPerformanceAnalyzerMetrics.emitMetric
that creates anEvent
from the serialized data and adds it to a static queue (PerformanceAnalyzerMetrics.metricQueue
) shared across all collectors.
- The collector will store serialized data in the
- suffixed by
-
collectors/StatsCollector
is a special collector that does not implementMetricsProcessor
. It writes to the"stats_log"
log whencollectMetrics
is called. -
metrics/PerformanceAnalyzerMetrics
contains logic for mapping events to files in the temporary filesystem used to store events, and the queue that contains events emitted by collectors. -
metrics/MetricsProcessor
is an interface used to obtain information about the key of a particular measurement and pushing it to the queue withsaveMetricValues
.- Note:
MetricsProcessor.getMetricsPath
provides the full identifier for a metric measurement: the epoch + key (for some collectors, the key is the corresponding string inPerformanceAnalyzerMetrics
) - Reading the path returned by
getMetricsPath
viagetMetric
will return the value of a metric.
- Note:
-
collectors/ScheduledMetricCollectorsExecutor
runs collectors periodically and updates their states based on whether they are still running at the next iteration (HEALTHY
,SLOW
, etc. defined inPerformanceAnalyzerMetricsCollector
). -
event_process/EventLogFileHandler
contains logic for writing events to files in the tmpfs. Used byEventLogQueueProcessor
. -
config/overrides/ConfigOverrides
andconfig/overrides/ConfigOverridesWrapper
can be used to piece-wise enable and disable components. They are used by the plugin in the Performance Analyzer repository. -
stats
contains code to aggregate and report metrics, along with service metrics such as latency of executions and occurences of events.ServiceMetrics
creates multipleSampleAggregator
s that track useful measurements. For example,STAT_METRICS_AGGREGATOR
,ERRORS_AND_EXCEPTIONS_AGGREGATOR
, etc.stats/SampleAggregator
is a class that tracks multiple related measurements and can dump them to a formatter. SampleAggregator can calculate multiple statistics (Min, Max, etc.) for a single measurement.SampleAggregator
s are created inServiceMetrics
by passing in all the variants of an enum that implementMeasurementSet
.- For example,
CollectorMetrics
is an enum that implementsMeasurementSet
.- It contains multiple measurements that should be tracked:
COLLECTORS_SKIPPED("CollectorSkippedCount", "namedCount", StatsType.STATS_DATA, Collections.singletonList(Statistics.NAMED_COUNTERS)),
- Code that wants to update the measurement calls to the corresponding
SampleAggregator
and passes the key of the measurement to update:ServiceMetrics.COMMONS_STAT_METRICS_AGGREGATOR.updateStat( StatMetrics.COLLECTORS_MUTED, collector.getCollectorName(), 1);
ExceptionsAndErrors
seems to only record certain errors in RCA; collectors and other code instead useStatExceptionCode
which does not write to anySampleAggregator
but instead directly writes to counters maintained inStatsCollector
.StatsCollector
is responsible for processing metrics aggregated atServiceMetrics
throughcollectMetrics
.- Every
collectMetrics
call emits 2 entries intoSTATS_LOGGER.debug
:- The first records the state of the counters that are maintained directly in
StatsCollector
; all the enum variants ofStatExceptionCode
are converted to strings and serve as keys to the counters. - The second entry records formatted reports from all the
SampleAggregators
insideServiceMetrics
.
- The first records the state of the counters that are maintained directly in
- Every
StatsReporter
wraps over a list ofSampleAggregator
s and writes out their reports to a formatter passed ingetNextReport
.ServiceMetrics
uses this class to wrap over the multipleSampleAggregator
s it abstracts over.