Azure App Insights Sample (ItemCount)

I have a question about Azure App Insights Sampling. If the itemCount field is greater than one for a journal item, does that mean the exact same request was received and it was selected?

There is one request in my logs that sends this message with itemCount = 2. And this request ended up with an OptimisticConcurrencyException, so my transaction was looped back. In this transaction, I am sending a message to a third party service. The most interesting thing is that they told me they have 2 messages from my service and my database is up to date (the transaction was committed). It all became clear if there were 2 requests, and one of them returned 200 codes and the other returned 500. But the log item app insight abot OptimisticConcurrencyException has itemCount = 2, which means this exception was thrown twice (for both requests) Also, apart from this, I don't see any other queries that could change the data, this query changed.

So can someone please explain to me how applications are requesting sample requests and errors?

+3


source to share


1 answer


It really depends on how / where your fetch happened, as the fetch could have happened in 3 different locations depending on how your application is configured.

There is a reliable amount of documentation for different sample levels , but hypothetically:

The sampling algorithm decides which telemetry items to discard and which ones to keep (whether in the SDK or in the Insight service). The sampling decision is based on several rules to preserve the integrity of all interconnected data points, preserving the diagnostic experience in Application Insights that is powerful and reliable even with a reduced dataset. For example, if your application sends additional telemetry items for a failed request (such as the exception and traces logged in this request), the fetch will not separate that request from other telemetry. He either holds or throws them all together. As a result, when you look at the details of a request in Application Insights, you can always see the request along with its associated telemetry items.



Update : I got some details from the people on the team who are sampling and it works like this:

  • The sampling rate is determined by the number of events per second that occur in the application
  • The AI ​​SDK randomly selects requests to be selected when the request starts (so it is not known if it will fail or succeed).
  • AI SDK assigns itemCount=<sampling ratio>

This then explains the behavior you see when two requests (success + failure) were considered two failures: the failed request was fetched "in" and so in telemetry you would have 2 failed requests (one request with itemCount = 2) instead of a failed one and successful because the successful one is selected.

+4


source







All Articles