|
19 | 19 | import java.util.concurrent.TimeUnit;
|
20 | 20 | import java.util.stream.IntStream;
|
21 | 21 |
|
| 22 | +import static org.elasticsearch.blobcache.BlobCacheMetrics.NON_ES_EXECUTOR_TO_RECORD; |
22 | 23 | import static org.hamcrest.Matchers.is;
|
23 | 24 |
|
24 | 25 | public class BlobCacheMetricsTests extends ESTestCase {
|
@@ -46,27 +47,28 @@ public void testRecordCachePopulationMetricsRecordsThroughput() {
|
46 | 47 | cachePopulationReason,
|
47 | 48 | cachePopulationSource
|
48 | 49 | );
|
| 50 | + String threadName = NON_ES_EXECUTOR_TO_RECORD; |
49 | 51 |
|
50 | 52 | // throughput histogram
|
51 | 53 | Measurement throughputMeasurement = recordingMeterRegistry.getRecorder()
|
52 | 54 | .getMeasurements(InstrumentType.DOUBLE_HISTOGRAM, "es.blob_cache.population.throughput.histogram")
|
53 | 55 | .get(0);
|
54 | 56 | assertEquals(throughputMeasurement.getDouble(), (double) mebiBytesSent / secondsTaken, 0.0);
|
55 |
| - assertExpectedAttributesPresent(throughputMeasurement, cachePopulationReason, cachePopulationSource, fileExtension); |
| 57 | + assertExpectedAttributesPresent(throughputMeasurement, cachePopulationReason, cachePopulationSource, fileExtension, threadName); |
56 | 58 |
|
57 | 59 | // bytes counter
|
58 | 60 | Measurement totalBytesMeasurement = recordingMeterRegistry.getRecorder()
|
59 | 61 | .getMeasurements(InstrumentType.LONG_COUNTER, "es.blob_cache.population.bytes.total")
|
60 | 62 | .get(0);
|
61 | 63 | assertEquals(totalBytesMeasurement.getLong(), ByteSizeValue.ofMb(mebiBytesSent).getBytes());
|
62 |
| - assertExpectedAttributesPresent(totalBytesMeasurement, cachePopulationReason, cachePopulationSource, fileExtension); |
| 64 | + assertExpectedAttributesPresent(totalBytesMeasurement, cachePopulationReason, cachePopulationSource, fileExtension, threadName); |
63 | 65 |
|
64 | 66 | // time counter
|
65 | 67 | Measurement totalTimeMeasurement = recordingMeterRegistry.getRecorder()
|
66 | 68 | .getMeasurements(InstrumentType.LONG_COUNTER, "es.blob_cache.population.time.total")
|
67 | 69 | .get(0);
|
68 | 70 | assertEquals(totalTimeMeasurement.getLong(), TimeUnit.SECONDS.toMillis(secondsTaken));
|
69 |
| - assertExpectedAttributesPresent(totalTimeMeasurement, cachePopulationReason, cachePopulationSource, fileExtension); |
| 71 | + assertExpectedAttributesPresent(totalTimeMeasurement, cachePopulationReason, cachePopulationSource, fileExtension, threadName); |
70 | 72 |
|
71 | 73 | // let us check for 0, avoid div by 0.
|
72 | 74 | checkReadsAndMisses(0, 0, 1);
|
@@ -107,10 +109,12 @@ private static void assertExpectedAttributesPresent(
|
107 | 109 | Measurement measurement,
|
108 | 110 | BlobCacheMetrics.CachePopulationReason cachePopulationReason,
|
109 | 111 | CachePopulationSource cachePopulationSource,
|
110 |
| - String fileExtension |
| 112 | + String fileExtension, |
| 113 | + String threadName |
111 | 114 | ) {
|
112 | 115 | assertThat(measurement.attributes().get(BlobCacheMetrics.CACHE_POPULATION_REASON_ATTRIBUTE_KEY), is(cachePopulationReason.name()));
|
113 | 116 | assertThat(measurement.attributes().get(BlobCacheMetrics.CACHE_POPULATION_SOURCE_ATTRIBUTE_KEY), is(cachePopulationSource.name()));
|
114 | 117 | assertThat(measurement.attributes().get(BlobCacheMetrics.LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY), is(fileExtension));
|
| 118 | + assertThat(measurement.attributes().get(BlobCacheMetrics.ES_EXECUTOR_ATTRIBUTE_KEY), is(threadName)); |
115 | 119 | }
|
116 | 120 | }
|
0 commit comments