|
16 | 16 |
|
17 | 17 |
|
18 | 18 | /** |
19 | | - * {@code BackupVersionOptimizationServiceStats} record the statistics for the database optimization done by the |
| 19 | + * {@code BackupVersionOptimizationServiceStats} records the statistics for the database optimization done by the |
20 | 20 | * {@link BackupVersionOptimizationService} including both successes and failures. |
21 | 21 | * |
22 | 22 | * <p>OTel uses a single COUNTER with STORE_NAME + OPERATION_OUTCOME dimensions. Tehuti uses |
@@ -53,23 +53,20 @@ public BackupVersionOptimizationServiceStats(MetricsRepository metricsRepository |
53 | 53 | } |
54 | 54 |
|
55 | 55 | public void recordBackupVersionDatabaseOptimization(String storeName) { |
56 | | - getOrCreateSuccessMetric(storeName).record(1, VeniceOperationOutcome.SUCCESS); |
| 56 | + getOrCreateMetric(successPerStore, storeName, TehutiMetricName.BACKUP_VERSION_DATABASE_OPTIMIZATION) |
| 57 | + .record(1, VeniceOperationOutcome.SUCCESS); |
57 | 58 | } |
58 | 59 |
|
59 | 60 | public void recordBackupVersionDatabaseOptimizationError(String storeName) { |
60 | | - getOrCreateErrorMetric(storeName).record(1, VeniceOperationOutcome.FAIL); |
| 61 | + getOrCreateMetric(errorPerStore, storeName, TehutiMetricName.BACKUP_VERSION_DATA_OPTIMIZATION_ERROR) |
| 62 | + .record(1, VeniceOperationOutcome.FAIL); |
61 | 63 | } |
62 | 64 |
|
63 | | - private MetricEntityStateOneEnum<VeniceOperationOutcome> getOrCreateSuccessMetric(String storeName) { |
64 | | - return successPerStore.computeIfAbsent( |
65 | | - storeName, |
66 | | - k -> createPerStoreMetric(k, TehutiMetricName.BACKUP_VERSION_DATABASE_OPTIMIZATION)); |
67 | | - } |
68 | | - |
69 | | - private MetricEntityStateOneEnum<VeniceOperationOutcome> getOrCreateErrorMetric(String storeName) { |
70 | | - return errorPerStore.computeIfAbsent( |
71 | | - storeName, |
72 | | - k -> createPerStoreMetric(k, TehutiMetricName.BACKUP_VERSION_DATA_OPTIMIZATION_ERROR)); |
| 65 | + private MetricEntityStateOneEnum<VeniceOperationOutcome> getOrCreateMetric( |
| 66 | + Map<String, MetricEntityStateOneEnum<VeniceOperationOutcome>> perStoreMap, |
| 67 | + String storeName, |
| 68 | + TehutiMetricName tehutiName) { |
| 69 | + return perStoreMap.computeIfAbsent(storeName, k -> createPerStoreMetric(k, tehutiName)); |
73 | 70 | } |
74 | 71 |
|
75 | 72 | private MetricEntityStateOneEnum<VeniceOperationOutcome> createPerStoreMetric( |
|
0 commit comments