diff options
author | Dimple Soni <dimple.soni@yoppworks.com> | 2021-08-12 18:50:29 -0400 |
---|---|---|
committer | Dimple Soni <dimple.soni@yoppworks.com> | 2021-08-18 10:28:14 -0400 |
commit | 9897b61766f53cf02d92d5debd9ec2457fb2750d (patch) | |
tree | e1eb570646a1b7c82ef7a985ad213029e35cec64 /aai-traversal | |
parent | fd3ec07e00ff409d92fea0a3ae11260669a9197a (diff) |
[AAI] Integrate Micrometer to identify slow APIs (Making aai_uri tag configurable)
Issue-ID: AAI-3367
Signed-off-by: Dimple Soni <dimple.soni@yoppworks.com>"
Change-Id: If8a5734c702242a292eeb6c9c26a844242e1f849
Diffstat (limited to 'aai-traversal')
4 files changed, 15 insertions, 5 deletions
diff --git a/aai-traversal/src/main/java/org/onap/aai/web/MicrometerConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/web/MicrometerConfiguration.java index 9b48dae..7c93e7d 100644 --- a/aai-traversal/src/main/java/org/onap/aai/web/MicrometerConfiguration.java +++ b/aai-traversal/src/main/java/org/onap/aai/web/MicrometerConfiguration.java @@ -22,6 +22,7 @@ import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tags; import io.micrometer.jersey2.server.JerseyTags; import io.micrometer.jersey2.server.JerseyTagsProvider; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.monitoring.RequestEvent; import org.springframework.context.annotation.Bean; @@ -31,6 +32,9 @@ import org.springframework.context.annotation.Configuration; * Configuration Class to add customized tags to http metrics scraped in /actuator/prometheus endpoint */ @Configuration +@ConditionalOnProperty( + value="scrape.uri.metrics", + havingValue = "true") public class MicrometerConfiguration { private static final String TAG_AAI_URI = "aai_uri"; private static final String NOT_AVAILABLE = "NOT AVAILABLE"; diff --git a/aai-traversal/src/main/resources/application.properties b/aai-traversal/src/main/resources/application.properties index 4ef501b..531cdc2 100644 --- a/aai-traversal/src/main/resources/application.properties +++ b/aai-traversal/src/main/resources/application.properties @@ -117,9 +117,11 @@ history.truncate.window.days=365 #To Expose the Prometheus scraping endpoint management.server.port=8448 #To Enable Actuator Endpoint, you can override this to True in OOM charts -management.endpoints.enabled-by-default=false +management.endpoints.enabled-by-default=true #To Enable Actuator Endpoint, you can override this in OOM Charts -#management.endpoints.web.exposure.include=info, health, prometheus +management.endpoints.web.exposure.include=info, health, prometheus management.metrics.web.server.auto-time-requests=false management.metrics.tags.group_id=aai -management.metrics.tags.app_id=${info.build.artifact} +# management.metrics.tags.app_id=${info.build.artifact} +#Enable this option only for debug purposes. For more information: https://github.com/micrometer-metrics/micrometer/issues/1584 +scrape.uri.metrics=true diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/ConfigurationTest.java index 891956d..5294f24 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/ConfigurationTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/ConfigurationTest.java @@ -40,6 +40,7 @@ import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; /** * Test REST requests against configuration resource @@ -86,9 +87,11 @@ public class ConfigurationTest extends AbstractSpringRestTest { responseEntity = restTemplate.exchange(actuatorurl + "/actuator/prometheus", HttpMethod.GET, httpEntity, String.class); responseBody = (String) responseEntity.getBody(); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); - assertTrue(responseBody.contains("app_id")); + System.out.println("responseBody---------" + responseBody); + assertFalse(responseBody.contains("aai_uri")); assertTrue(responseBody.contains("group_id")); + //Set Accept as MediaType.APPLICATION_JSON in order to get access of endpoint "/actuator/info" and "/actuator/health" headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); httpEntity = new HttpEntity<String>(headers); diff --git a/aai-traversal/src/test/resources/application-test.properties b/aai-traversal/src/test/resources/application-test.properties index b763c59..8bf4f9d 100644 --- a/aai-traversal/src/test/resources/application-test.properties +++ b/aai-traversal/src/test/resources/application-test.properties @@ -86,4 +86,5 @@ schema.translator.list=config management.server.port=0 management.endpoints.enabled-by-default=true management.endpoints.web.exposure.include=info, health, prometheus -management.metrics.web.server.auto-time-requests=false
\ No newline at end of file +management.metrics.web.server.auto-time-requests=false +scrape.uri.metrics=true
\ No newline at end of file |