Spring AOP (Aspect-Oriented Programming | | | Default logging level of “logging.level.org.onap.cps” is set to “INFO”.  to change this, set line 194 (logging.level.org.onap.cps to DEBUG) Changing logging level dynamically see Change logging level
| can control easily which packages and/or methods to run by changing the constants no repetitive code for debugging all method performances to see when methods are executed, their parameters, return values etc. “@Around"/@Before/@After annotation takes other expressions to specify to Spring which methods you want to monitor , can be based on their name, parameters, or return type…examples: @Around("execution(* org.thirdparty.library.*.*(..))") - only intercepts methods of the given library @Around("execution(*org.onap.cps.*.*(org.onap.TrustLevel))") - only intercepts methods with TrustLevel as first parameter
|
MicroMeter | allows to collect metrics with use of annotation integrates with Spring boot Actuator TimedAspect (micrometer class) uses AOP Annotation and set up enabled by default
| | | what can we get?all metrics are stored and can be collected (from MeterRegistry) and exported to monitoring systems like Prometheus metrics: counters, gauges, timers HTTP request metrics response times, request counts etc JVM metrics (memory usage,garbage collection, thread count, class loading stats) Datasource metrics (connection pool stats) System metrics (disk space, CPU usage etc)
sample actuator/prometheus output sample /actuator/metrics/cps.module.service.schemaset.create output add metric to actuator endpoint exposure -management.endpoint.web.exposure.include: info,health,loggers,prometheus,metric 
|
OpenTelemetry uses jaeger to sample console and log for metrics | end-to-end tracing (tracing requests across services) OpenTelemetry - open-source set of APIs, libraries, agents, and instrumentation to monitor application. Allows to collect metrics, logs, and traces Jaeger - open-source distributed tracing system used with OpenTelemetry to visualise traces and understand flow of requests ** we use OpenTelemetry to send trace data to Jaeger and view it in Jaeger UI Annotation and set up OpenTelemetryConfig.java Code Block |
---|
@Value("${spring.application.name:cps-application}")
private String serviceId;
@Value("${cps.tracing.exporter.endpoint:http://onap-otel-collector:4317}")
private String tracingExporterEndpointUrl;
@Value("${cps.tracing.sampler.jaeger_remote.endpoint:http://onap-otel-collector:14250}")
private String jaegerRemoteSamplerUrl;
@Value("${cps.tracing.excluded-observation-names:tasks.scheduled.execution}")
private String excludedObservationNamesAsCsv; |
serviceId : states the application to be monitored tracingExporterEndpointUrl : (OpenTelemetry collector endpoint) this is where traced data by openTelemetry will be exported jaegerRemoteSamplerUrl : (remote sampler endpoint) this controls the sampling trace behaviour
Code Block |
---|
| @Bean
@ConditionalOnExpression(
"${cps.tracing.enabled} && 'grpc'.equals('${cps.tracing.exporter.protocol}')")
public OtlpGrpcSpanExporter createOtlpExporterGrpc() {
return OtlpGrpcSpanExporter.builder().setEndpoint(tracingExporterEndpointUrl).build();
}
@Bean
@ConditionalOnExpression(
"${cps.tracing.enabled} && 'http'.equals('${cps.tracing.exporter.protocol}')")
public OtlpHttpSpanExporter createOtlpExporterHttp() {
return OtlpHttpSpanExporter.builder().setEndpoint(tracingExporterEndpointUrl).build();
}
|
Code Block |
---|
@Bean
@ConditionalOnProperty("cps.tracing.enabled")
public JaegerRemoteSampler createJaegerRemoteSampler() {
return JaegerRemoteSampler.builder()
.setEndpoint(jaegerRemoteSamplerUrl)
.setPollingInterval(Duration.ofSeconds(JAEGER_REMOTE_SAMPLER_POLLING_INTERVAL_IN_SECONDS))
.setInitialSampler(Sampler.alwaysOff())
.setServiceName(serviceId)
.build();
} |
Code Block |
---|
@Bean
@ConditionalOnProperty("cps.tracing.enabled")
public ObservationRegistryCustomizer<ObservationRegistry> skipActuatorEndpointsFromObservation() {
final PathMatcher pathMatcher = new AntPathMatcher("/");
return registry ->
registry.observationConfig().observationPredicate(observationPredicate(pathMatcher));
}
private ObservationPredicate observationPredicate(final PathMatcher pathMatcher) {
return (observationName, context) -> {
if (context instanceof ServerRequestObservationContext observationContext) {
return !pathMatcher.match("/actuator/**", observationContext.getCarrier().getRequestURI()); |
currently excludes all CPS scheduled tasks
} else {
return !excludedObservationNames.contains(observationName);
}
};
} |
| | disabled by default run CPS via docker-compose file with ‘tracing’ profile access tracing through accessing http://localhost:16686 in browser Use Jaeger's UI to spot service anomalies, high latencies, or errors in real-time. identify where failures or performance issues occur in the service chain sample operations traced after registering cm handle Image Removed
| ** Trace shows the journey of the request flow. It is made up of spans which shows each operations ** Each span has metadata: id ,start and end time, operation name (i.e. HTTP GET), status code, response time etc..
What gets traced? HTTP Requests (Inbound) when requests comes in , trace is generated. The span for this could have http method, url path, status code, time taken to process the request etc…
Internal Service Calls (Outbound) when cps makes an outbound http call to another service , trace is created. span can include url of the called service,http method, status code, duration of the call
Database Queries Method Calls within Your Application (Service Layer) Asynchronous Operations External System Calls Error Handling (Exceptions)
|