Pull request #6: RED-4609 - added ocr metric, enabled prometheus, added test for metric
Merge in RED/ocr-service from RED-4609 to master * commit '7c71d8ad041f839c21ec26023ee8eaef670a4924': RED-4609 - added ocr metric, enabled prometheus, added test for metric
This commit is contained in:
commit
efaa291e43
@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -57,6 +58,7 @@ public class OCRService {
|
||||
* @return the resulting PDF file as an InputStream
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Timed("redactmanager_runOcrOnDocument")
|
||||
public InputStream runOcrOnDocument(String dossierId, String fileId) {
|
||||
|
||||
InputStream fileStream = fileStorageService.getOriginalFileAsStream(dossierId, fileId);
|
||||
|
||||
@ -35,7 +35,7 @@ management:
|
||||
metrics.enabled: ${monitoring.enabled:false}
|
||||
prometheus.enabled: ${monitoring.enabled:false}
|
||||
health.enabled: true
|
||||
endpoints.web.exposure.include: prometheus, health
|
||||
endpoints.web.exposure.include: prometheus, health, metrics
|
||||
metrics.export.prometheus.enabled: ${monitoring.enabled:false}
|
||||
|
||||
|
||||
@ -46,4 +46,4 @@ storage:
|
||||
endpoint: 'https://s3.amazonaws.com'
|
||||
backend: 's3'
|
||||
|
||||
pdftron.license: ${PDFTRON_LICENSE}
|
||||
pdftron.license: ${PDFTRON_LICENSE}
|
||||
|
||||
@ -7,7 +7,10 @@ import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
import io.micrometer.prometheus.PrometheusTimer;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@ -62,6 +65,9 @@ public class OcrServiceIntegrationTest {
|
||||
@Autowired
|
||||
private OCRService ocrService;
|
||||
|
||||
@Autowired
|
||||
private PrometheusMeterRegistry registry;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@SneakyThrows
|
||||
@ -72,6 +78,21 @@ public class OcrServiceIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Disabled // OCRModule is not available on build server. If you want to run the test set the property at the top.
|
||||
public void testOCRMetrics(){
|
||||
testOCR("Watermark");
|
||||
testOCR("Watermark");
|
||||
testOCR("Watermark");
|
||||
|
||||
var ocrOnDocumentMeter = registry.getMeters().stream()
|
||||
.filter(m -> m.getId().getName().equalsIgnoreCase("redactmanager_runOcrOnDocument")).findAny();
|
||||
assertThat(ocrOnDocumentMeter.isPresent()).isTrue();
|
||||
PrometheusTimer timer = (PrometheusTimer) ocrOnDocumentMeter.get();
|
||||
assertThat(timer.count()).isEqualTo(3);
|
||||
assertThat(timer.mean(TimeUnit.SECONDS)).isGreaterThan(0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // OCRModule is not available on build server. If you want to run the test set the property at the top.
|
||||
public void testOcr() {
|
||||
|
||||
@ -5,4 +5,13 @@ spring:
|
||||
allow-circular-references: true # FIXME
|
||||
|
||||
|
||||
pdftron.license: demo:1650351709282:7bd235e003000000004ec28a6743e1163a085e2115de2536ab6e2cfe5a
|
||||
pdftron.license: demo:1650351709282:7bd235e003000000004ec28a6743e1163a085e2115de2536ab6e2cfe5a
|
||||
|
||||
|
||||
management:
|
||||
endpoint:
|
||||
metrics.enabled: true
|
||||
prometheus.enabled: true
|
||||
health.enabled: true
|
||||
endpoints.web.exposure.include: prometheus, health, metrics
|
||||
metrics.export.prometheus.enabled: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user