Class MetricsJsonExporter
java.lang.Object
de.cuioss.benchmarking.common.metrics.MetricsJsonExporter
Exports metrics data to JSON files in a target directory.
Handles JSON serialization, file writing, and metrics aggregation.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMetricsJsonExporter(Path targetDirectory) Creates a new metrics JSON exporter. -
Method Summary
Modifier and TypeMethodDescriptionvoidexportJwtValidationMetrics(String benchmarkMethodName, Instant timestamp, Map<String, Double> allMetrics) Exports JWT validation metrics for a specific benchmark method.voidexportResourceMetrics(Instant timestamp, Map<String, Double> allMetrics) Exports resource metrics (CPU, memory) for system monitoring.voidexportToFile(String fileName, Map<String, Object> metricsData) Exports metrics data to a JSON file.readExistingMetrics(String fileName) Reads existing metrics from a JSON file.voidUpdates an aggregated metrics file with new benchmark data.
-
Field Details
-
BEARER_TOKEN_RESULT
- See Also:
-
-
Constructor Details
-
MetricsJsonExporter
Creates a new metrics JSON exporter.- Parameters:
targetDirectory- Directory where JSON files will be written
-
-
Method Details
-
exportToFile
Exports metrics data to a JSON file.- Parameters:
fileName- The name of the JSON filemetricsData- The metrics data to export- Throws:
IOException- if writing fails
-
exportJwtValidationMetrics
public void exportJwtValidationMetrics(String benchmarkMethodName, Instant timestamp, Map<String, Double> allMetrics) throws IOExceptionExports JWT validation metrics for a specific benchmark method.- Parameters:
benchmarkMethodName- The name of the benchmark methodtimestamp- The timestamp when the benchmark was executedallMetrics- All metrics data- Throws:
IOException- if export fails
-
exportResourceMetrics
public void exportResourceMetrics(Instant timestamp, Map<String, Double> allMetrics) throws IOExceptionExports resource metrics (CPU, memory) for system monitoring.- Parameters:
timestamp- The timestamp when metrics were collectedallMetrics- All metrics data- Throws:
IOException- if export fails
-
updateAggregatedMetrics
public void updateAggregatedMetrics(String fileName, String benchmarkName, Map<String, Object> benchmarkData) throws IOExceptionUpdates an aggregated metrics file with new benchmark data. For quarkus-metrics.json files, applies special transformation to create the new structure.- Parameters:
fileName- The name of the aggregated metrics filebenchmarkName- The name of the benchmarkbenchmarkData- The benchmark data to add/update- Throws:
IOException- if writing fails
-
readExistingMetrics
Reads existing metrics from a JSON file.- Parameters:
fileName- The name of the JSON file- Returns:
- The parsed metrics map, or empty map if file doesn't exist or is empty
-