Reputation: 13
unfortunately i'm not able to trace correctly my applications with Application Insight.
My Spring Boot project exposes a series of @HttpTriggers and @ServiceBusTriggers through the spring-cloud-function-adapter-azure library and below I will show you an example with two of these triggers (but the problem with application insight correlation exists on all of them): HelloWorldProducerTrigger and FooProducerTrigger.
First of all, I've imported the applicationinsights-agent library among the dependencies of my project and the maven-dependency-plugin configuration as defined in:
https://github.com/Azure-Samples/ApplicationInsights-Java-Samples/blob/main/maven/pom.xml
and subsequently inserted the prop APPLICATIONINSIGHTS_CONNECTION_STRING among the properties of my function, in the Configuration section.
After deploying the function I tried to call my HelloWorldProducerTrigger api (/api/v2/hello-world) which in turn calls the FooProducerTrigger api (api/v2/foo) via a POST but in the end to end dashboard of my application insight requests are not related to each other: enter image description here enter image description here
Analyzing the headers of my requests I noticed that Azure injects the W3C TraceContext "traceparent" attribute into the headers of each request as defined in the standard https://learn.microsoft.com/en-us/azure/azure-monitor/app/distributed-trace-data, but we can see below that the traceparent of HelloWorldProducerTrigger:
"traceparent":"00-6d2fe7dfd8e3458b4baf94eb9825cd3d-cdd14db2bf0f112f-00" OperationId: 6d2fe7dfd8e3458b4baf94eb9825cd3d ParentId: cdd14db2bf0f112f
and that of FooProducerTrigger have a different operationId (so i think that the correlation problem is that)
"traceparent":"00-5104fa229a07a7b3eeda5129ca1b7c66-4e4cb97be05bb545-00" OperationId: 5104fa229a07a7b3eeda5129ca1b7c66 ParentId: 4e4cb97be05bb545
What should I do to properly self-instrumentate my Spring Boot projects?
From the following guide I expected that once the applicationinsights-agent library was imported, my application would be self-instrumented and therefore I would see the correctly related calls on App Insight.
https://learn.microsoft.com/it-it/azure/azure-monitor/app/opentelemetry-enable?tabs=java
Thank you!
Upvotes: 0
Views: 1428
Reputation: 3448
Thanks @paizo, I agree with him and also as per the MS documentation which I followed that you could check below.
What should I do to properly self-instrumentate my Spring Boot projects?
You need to check that the traceparent
headers are propagated correctly and consistently across the application components. In your case which you're seeing different OperationId
values for different requests means that the correlation might not be set up correctly.
From the following guide I expected that once the applicationinsights-agent library was imported, my application would be self-instrumented and therefore I would see the correctly related calls on App Insight.
Yes, it's true even if in my case I have created same scenario in my environment, and it works as-well.
applicationinsights-agent
dependency to your pom.xml
file.Microsoft Application Insights Java Agent:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-Core</artifactId>
<version>3.4.19</version>
</dependency>
HttpTrigger:
Servicebus Queue trigger:
Reference:
Updated Dependency:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-agent</artifactId>
<version>3.4.19</version>
</dependency>
Upvotes: 0