How to Demo Application Insights Auto-Instrumentation Features?

Siegfried Heintze 1,906 Reputation points
2022-12-14T18:52:00.337+00:00

I'm looking at Application Insights Auto-Instrumentation Support and would like to demo this for a prospective client.

  1. Can I use this console mode example? there are comments in the C# that say "Http dependency is automatically tracked!" and while I can see my TrackTrace statements in the logs, I cannot see any reference to the httpclient. Perhaps someone could provide the appropriate kusto query or powershell command to see this?
  2. Is this http dependency that is supposed to be logged an example of Auto-Instrumentation support? If so, is there a mistake because don't see C# .NET Core console mode programs running on-prem listed as supporting Auto-instrumentation.
  3. Please supply some guidance for demonstrating this instrumentation feature. What features should I put in my console mode code to demonstrate it?
  4. How would I view the results? What would be some kusto queries to see the log entries?
  5. Is there a java version of the C# demo somewhere so I could just run it on my windows notebook? I see "Standalone agent - any environment" supports java programs for auto-instrumentation. Does this include a java console mode program running on my windows notebook computer? How would I proceed? Would I just translate the C# program to java in the previous link?
  6. It also says "Azure VM Windows"... I've never tried Github Code spaces but I hear they have some cheap developer VMs already configured for development. Would this environment support the auto-instrumentation feature? This would be easier & faster than creating my own windows azure VM and installing visual studio on it.
  7. Maybe the easiest approach would be a Linux Azure App Service/.NET Core published as code. Does this include Blazor Server? Then I could create some simple push buttons to trigger the auto-instrumentation features. Could I expect to see the results of auto-instrumentation immediately with a kusto query inside application insights?

Thanks

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,662 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,551 Reputation points Moderator
    2022-12-20T05:50:23.603+00:00

    Hi @Siegfried Heintze ,

    Please find below the response your queries:

    1. Application Insights Auto-Instrumentation is a way to enable ApplicationInsights tracing in your application without requiring code changes.. For the console application, Auto Instrumentation is not available, as there are some code changes required in console application for it to be able to send telemetry to ApplicationInsights. For example, in the code snippet available in Application Insights for .NET console applications, it would require adding some lines in the code itself - for example the following snippets:

    TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault();  
    configuration.ConnectionString = "removed";  
    configuration.TelemetryInitializers.Add(new HttpDependenciesParsingTelemetryInitializer());  
    var telemetryClient = new TelemetryClient(configuration);  
    

    You can still use "Application Insights" to monitor .NET console applications, as mentioned in the article, but it cannot be enabled using "Auto Instrumentation".

    The dependency related information (in the example, related to HttpClient), it will be available in "dependencies" table of ApplicationInsights. Please see this link for list of tables available and the data they contain.

    2. No, "Auto-Instrumentaion" only means a way to enable Application Insights without requiring any code changes. The other way of enabling ApplicationInsights is by using the SDK directly, which requires creating instance of AppInsights classes and calling its method (as seen in the console application example).

    3. If you would like to demonstrate Auto-Instrumentation, you would have to use one of the supported frameworks and languages, as available in this link. You could follow the link below which contains complete training with documentation required to learn this feature. This training path also contains details about viewing some of the commonly collected information in Azure portal through various visualization tools available.
    Capture and view page load times in your Azure web app with Application Insights

    4. The data collected by ApplicationInsights can be viewed from various views/dashboards available in "Applicaiton Insights" or by querying the logs directly. Please follow the tutorial set available here - Application Insights tutorials. Various sections are available, as highlighted below and each contains details about the various ways to view data for a typical scenario.
    272296-image.png

    Alternatively, you could query raw data from various tables directly by using the Kusto Query Language in "Logs" of ApplicationInsights resource. Tha available tables are listed here - Table structure

    5. Enabling ApplicationInsights for Java application follows a different path. Here, you download a jar file (applicationinsights-agent-XX.jar) and provide its path as parameter to JVM using -javaagent: parameter. Please see the following link for more details - Azure Monitor OpenTelemetry-based auto-instrumentation for Java applications

    6. GitHub codespaces is a developer environment in the cloud that starts in seconds. It is similar to having your own machine with required tools (VS Code, Jupyter, or JetBrains) installed. If you are only interested in trying out ApplicationInsights, you don't need codespace or a VM in Azure. You can use your own machine (laptop, desktop or notebook) with VS code/Visual studio etc. on it, to develop application, run it locally and send telemetry to ApplicationInsights to view result.
    The Supported environments, languages, and resource providers table also mentioned links to respective tutorial/steps which can be used to configure that particular option. For example, see the following image -

    272362-image.png

    7. Yes, you could do that. Or you could simply enable applicationInsights in your application from the IDE that you are using, run it locally and view collected data in ApplicationInsights in Azure Portal. For data to flow from application to ApplicationInsights, the application need not be published to Azure. Please see this link for details - Application Insights for ASP.NET Core applications
    This would work for blazer server as well or any type of Asp.Net Core application.
    You could also explore the following link, which contains advance usage scenarios - Application Insights API for custom events and metrics

    To check whether data is being received by ApplicationInsights, you can use either of the following:

    • Live Metrics: which shows collected metrics in near real time. This can be used to ensure that data is getting to ApplicationInsights.
    • Alternatively, you could use the following query in "Logs" section to see if any data is getting to ApplicationInsights. Using the query (union *) in Kusto will give you a union of all data in all tables in the ApplicationInsights workspace. You can see the itemType column in the result to know the name of table from which that particular row is pulled.
      union *

    I hope the information above helps. Please let me know if you have any questions.

    ---
    Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.