kfaraz commented on code in PR #14453:
URL: https://github.com/apache/druid/pull/14453#discussion_r1238487258
##########
sql/src/test/java/org/apache/druid/sql/calcite/schema/SegmentMetadataCacheTest.java:
##########
@@ -1447,6 +1460,31 @@ public void testStaleDatasourceRefresh() throws
IOException, InterruptedExceptio
Assert.assertNull(schema.getDatasource("wat"));
}
+ @Test
+ public void testRefreshShouldEmitMetrics() throws InterruptedException
+ {
+ ServiceEmitter mockEmitter = Mockito.mock(ServiceEmitter.class);
+ Map<String, ServiceMetricEvent> emittedEvents = new HashMap<>();
+
Mockito.doCallRealMethod().when(mockEmitter).emit(ArgumentMatchers.any(ServiceEventBuilder.class));
+ Mockito
+ .doAnswer(invocation -> {
+ ServiceMetricEvent e = invocation.getArgument(0);
+ emittedEvents.put(e.getMetric(), e);
+ return null;
+ })
+ .when(mockEmitter).emit(ArgumentMatchers.any(Event.class));
+
+ buildSchemaMarkAndTableLatch(SEGMENT_CACHE_CONFIG_DEFAULT, mockEmitter);
+
+ Assert.assertTrue(emittedEvents.containsKey("init/metadatacache/time"));
+
Assert.assertEquals(emittedEvents.get("segment/metadatacache/refresh/count")
+ .getUserDims()
+ .get(DruidMetrics.DATASOURCE),
"some_datasource");
+ Assert.assertEquals(emittedEvents.get("segment/metadatacache/refresh/time")
Review Comment:
`getMetricValues` can be used for that too because it allows you to pass a
set of dimension filters. See some of the other tests where it is being used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]