I have a spring boot version, and applicationinsights-runtime-attach dependencies. Before main method, ApplicationInsights.attach() gets executed and the instrument key from json is getting picked but when it goes to run method of the main class, that is runApplication, it initialises the aiAppender class from spring-logback.xml, where in the instrument key comes as null.
My task is to publish the logs to application insights from springboot application and to create a dashboard using these appins (basically performance benchmarking). Specifically, time taken for a transaction. For that, I have annotated the methods with custom annotation @Timed
I have tried following steps:
Adding the Dependencies: {spring boot version - 2.7.12}
a. com.microsoft.azure:applicationsinsights-springboot-starter,2.6.4
b. com.microsoft.azure: applicationsinsights-logging-logback,2.6.4 dependency for ApplicationInsightsAppender
c. com.microsoft.azure: applicationsinsights-runtime-attach,3.4.14
d. com.microsoft.azure: applicationsinsights-core, 3.4.14
Connection string in yaml files as well as json
Applicationinsights.attach before runApplication method in main class
aiAppender in spring-logback.xml
@Timed custom annotation.
TimingAspect.java class having @Around(Timed package) { calculating execution time} This method also send the event using EventTelemetry i.e. TelemetryClient.trackEvent(event) where event is set with two properties; method name and execution time.
Annotated the methods with @Timed to capture their duration.
Kindly provide with the appropriate steps to send these logs to appins
Configure the logback debug statements and print the status messages to the console during application startup.
spring-logback.xml:
TimingAspect
class to capture the method execution time.build.gradle:
TimingAspect:
Main class:
App Insights: