Welcome!

Blog Feed Post

Application Insights – 15 things every developer needs to know

Application Insights is Microsoft’s lightweight application performance monitoring service. I have collected a nice list of things that every developer should know. Including tips, key features, and limitations.

1. Make sure your app targets .NET 4.6, and .NET 2.0 is not supported

There are some changes in the 4.6 version of the .NET framework that enable some additional data collection abilities for Application Insights. Be sure to update your app and redeploy it. App Insights will work with 4.5 or newer but 4.6 is preferred.

I know it sounds crazy, but you wouldn’t believe how many people have older apps written in 2.0 that they still have to support and have never been upgraded. App Insights does not support 2.0 and they don’t have any plans to do so.

2. Warning! Sensitive data is not scrubbed from dynamic SQL queries

If your code uses dynamic SQL, Application Insights will collect the full query and upload it to Azure. This means if the query contained personal information, credit card numbers, or anything else that could be sensitive, it is getting uploaded from your server to Microsoft.

Another thing to know on this topic, App Insights never collect SQL parameters.

3. Key limitation: Finding slow SQL queries

Application insights provides reporting down to the server and database name being accessed. There is no to see how long individual queries take, which are the slowest, or being called the most often. There is also no way to setup monitoring for a specific SQL query.

To get a list of slow SQL queries, you would need to query SQL Server’s DMVs or use a different APM solution. If you are using SQL Azure it is has some built in tuning advisor functions for this too.

4. Azure App Services require a site extension for all features

You can add Application Insights to your project and deploy it to Azure as an App Service. App Insights will seem to work, but there are some things that don’t work until you install the site extension. You can install it via the Azure Portal. I specifically noticed full SQL queries were not collected without it.

5. View top exceptions in your application

Application insights has good reporting to group application exceptions so you can uniquely see which ones are occurring and how often.

application insights exceptionshttp://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 300w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 1350w" sizes="(max-width: 600px) 100vw, 600px" />

How to send exceptions to App Insights

To ensure that all of your exceptions are collected you must install their SDK and make some code and config changes.

  1. Modify code to collect unhandled exceptions for MVC, global.asax, etc.
  2. If you use log4net, NLog, etc you can configure it to send your exceptions
  3. Manually report exceptions via their SDK if needed

Limitations and missing exceptions features

App Insights is missing some key features around exceptions. If you are having SQL timeouts for example, odds are they impact multiple applications. App Insights has no reporting across apps to easily see this.

  1. No way to see exceptions across all applications
  2. Some other APM solutions don’t require any code or config changes to collect unhandled exceptions
  3. No way to collect all “first chance” exceptions

Retrace can collect all exceptions, including first chance exceptions, with no code changes.

6. Asynchronous HttpClient calls are not supported

Almost all new ASP.NET development is now done in async and uses the common async/await pattern. Unfortunately, Application Insights does not support the recommended way to make HTTP calls with ASP.NET.

        public async Task HttpClientAsync()
        {
            log.Debug("Starting HttpClient.GetStringAsync()");
            string data;
            using (HttpClient hc = new HttpClient())
            {
                data = await hc.GetStringAsync("http://microsoft.com");
            }

            log.Debug("Completed HttpClient.GetStringAsync()");

            return Request.CreateResponse(HttpStatusCode.OK, data);
        }

App Insights does pick up the 2 logging messages via log4net, but doesn’t show anything for dependency calls.

http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 300w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 1024w" sizes="(max-width: 600px) 100vw, 600px" />

It does see it, it just doesn’t associate it with the ASP.NET web request.

http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 300w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 1024w" sizes="(max-width: 600px) 100vw, 600px" />

7. Tracking application dependencies

App Insights supports tracking dependency calls in your code. Microsoft’s documentation says SQL databases, HTTP calls, and Azure storage libraries are supported. Anything else requires using their SDK to manually track each dependency call.

Limitations

App Insights does not support some other notable key Azure dependencies include Service Bus and redis.

Some other APM solutions also support MongoDB, RavenDB, Elasticsearch, Redis, Memcached, AppFabric, MSMQ, NServiceBus, AWS services and more.

8. View all details for a single web request (transaction trace)

One of the key features to help track down what a request does is seeing the complete picture of logging, dependency calls, and other key events associated with a single web request.

The best way to do this in Application Insights is to click “All available telemetry for this operation”.

http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 285w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 974w" sizes="(max-width: 600px) 100vw, 600px" />

 

9. How to Identify why a request or entire application is slow

One suggestion is to customize the chart that you see when filter for a specific operation to add the “dependency duration”. This will help you see how that compares to overall server response time.

http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 300w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 1024w" sizes="(max-width: 1797px) 100vw, 1797px" />

Application Insights’ map feature can be useful for trying to identify the performance of dependencies. It will tell you the average time and % of failures.

http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 300w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 1024w" sizes="(max-width: 1082px) 100vw, 1082px" />

I would also suggest going to “Failures” from the menu to look for dependency failures and exceptions.

One thing that would be nice is a visual way to see how each dependency impacts overall performance. When there is a problem with one it is usually easy to see it spike.

http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 300w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 768w, http://1piygz303e2p3ze2nt2kfhla.wpengine.netdna-cdn.com/wp-content/uploa... 1024w" sizes="(max-width: 1379px) 100vw, 1379px" />
Screenshot from Retrace

10. Monitoring & Alerts features and limitations

Application Insights supports configuring alerts for a lot of different conditions. Including alerting on metrics like Server Exceptions, Request Rate, Process CPU, etc.

Monitoring limitations

  • No way to monitor a specific request (URL/action)
  • No way to monitor a specific SQL query
  • No way to monitor % of requests having errors
  • Can only monitor averages

Alerting limitations

  • Email or webhooks only
  • Can use a Logic App to send to SMS, Slack, and others
  • No built in concept of alert “escalation”
  • No concept of alert severity like warning vs critical
  • Alerts go to everyone or a hard coded list of emails. No good way to manage distribution lists unless done outside via email groups.

11. Reporting across applications

In Azure Application Insights, each app is more or less a “bucket” that all the diagnostics about each app gets reported to. There is no easy way to see exceptions, slow SQL queries, slow web requests and etc across all of your apps. The only workaround that can provide some very minimal visibility is making a custom dashboard and selecting some widgets across multiple apps.

12. Application Insights does support the concept of multiple “environments” (QA, Prod, etc)

Within an individual application, there is no high level way to separate out and report data by environment (i.e. Dev, QA, Prod). Microsoft has a couple workarounds that they recommend:

  1. Configure a unique “application” via separate instrumentation keys. This works but then there is no reporting across them. They are completely isolated.
  2. Use a custom field for the environement. You would then need to probably make your own dashboards and widgets in App Insights filtered down by that custom field.

13. App Insights is not a code profiler

Most application performance management (APM) solutions use code profiling to do data collection. Microsoft Application Insights does not use profiling. Instead it relies on collecting data via the .NET framework via ETW and other sources.

Because App Insights does not the CLR profiler, it causes a few limitations:

  • Lack of dependency support – The reason Microsoft Application Insights does not support a wide array of 3rd party dependencies is primarily because they don’t do code profiling that would let them instrument the libraries.
  • No custom profiling – One of the very useful features of APM solutions is being able to profile custom methods in your code to track their usage and performance. App Insights doesn’t support this. You would instead need to use their SDK and modify your code to report it.

14. Application Insights has a robust API, and you will likely need it

If you like instrumenting your apps manually to report performance data, you will love Application Insights. They have a robust API and SDKs for several programming languages  (.NET, java, node.js) that let’s you report requests, pages views, dependency calls, trace (log) messages, exceptions and more via their TelemetryClient.

Microsoft’s own description highlights it as being “extensible” as it relies on a lot of custom SDK usages to get rich data.

Application Insights is an extensible Application Performance Management (APM) service for web developers.

If your app uses Elasticsearch, mongodb, redis, or any other dependency and you would like to see it show up in Application Insights on Azure, you will need to change your code and manually report it.

15. How to use Application Insights with Windows Services

If you have a Windows Service type application that you want to track with App Insights, you will have to integrate their API in to your app. Every single place you make a database call, you can simply add a couple lines of code to report the query via their SDK.

As an example, check out this article about using Azure Worker Roles with Application Insights.

Need more than Application Insights?

Application Insights is awesome. However, like any application, it has its limitations and best use cases. I would describe App Insights as a “light APM” solution. If you want to take the time to use their SDK, you can make it do a lot of different things.

However, if you want the best APM available for ASP.NET developers with the entire goal of finding and fixing application problems as fast as possible, checkout Retrace. It is actually written in ASP.NET and is hosted on Azure. Monitoring Azure is our expertise!

Key differences:

  • All major application dependencies supported
  • Excellent reporting across apps and environments
  • Industry leading transaction trace views for developers
  • 100% support for async and .NET Core
  • Included and advanced logging functionality
  • No code or config changes required

The post Application Insights – 15 things every developer needs to know appeared first on Stackify.

Read the original blog entry...

More Stories By Stackify Blog

Stackify offers the only developers-friendly solution that fully integrates error and log management with application performance monitoring and management. Allowing you to easily isolate issues, identify what needs to be fixed quicker and focus your efforts – Support less, Code more. Stackify provides software developers, operations and support managers with an innovative cloud based solution that gives them DevOps insight and allows them to monitor, detect and resolve application issues before they affect the business to ensure a better end user experience. Start your free trial now stackify.com

Latest Stories
SYS-CON Events announced today that Linux Academy, the foremost online Linux and cloud training platform and community, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Linux Academy was founded on the belief that providing high-quality, in-depth training should be available at an affordable price. Industry leaders in quality training, provided services, and student certification passes, its goal is to c...
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm. In his Day 3 Keynote at 20th Cloud Expo, Chris Brown, a Solutions Marketing Manager at Nutanix, will explore t...
Providing the needed data for application development and testing is a huge headache for most organizations. The problems are often the same across companies - speed, quality, cost, and control. Provisioning data can take days or weeks, every time a refresh is required. Using dummy data leads to quality problems. Creating physical copies of large data sets and sending them to distributed teams of developers eats up expensive storage and bandwidth resources. And, all of these copies proliferating...
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
SYS-CON Events announced today that StorageCraft Technology Corp, a global leader in backup and disaster, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. The StorageCraft family of companies, founded in 2003, provides award-winning backup, disaster recovery, system migration and data protection solutions for servers, desktops and laptops in addition to powerful data analytics.
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), will provide an overview of various initiatives to certifiy the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldw...
SYS-CON Events announced today that Auditwerx will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Auditwerx specializes in SOC 1, SOC 2, and SOC 3 attestation services throughout the U.S. and Canada. As a division of Carr, Riggs & Ingram (CRI), one of the top 20 largest CPA firms nationally, you can expect the resources, skills, and experience of a much larger firm combined with the accessibility and attent...
SYS-CON Events announced today that Technologic Systems Inc., an embedded systems solutions company, will exhibit at SYS-CON's @ThingsExpo, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Technologic Systems is an embedded systems company with headquarters in Fountain Hills, Arizona. They have been in business for 32 years, helping more than 8,000 OEM customers and building over a hundred COTS products that have never been discontinued. Technologic Systems’ pr...
SYS-CON Events announced today that CA Technologies has been named “Platinum Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY, and the 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business – from apparel to energy – is being rewritten by software. From ...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend @CloudExpo | @ThingsExpo, June 6-8, 2017, at the Javits Center in New York City, NY and October 31 - November 2, 2017, Santa Clara Convention Center, CA. Learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
HyperConvergence came to market with the objective of being simple, flexible and to help drive down operating expenses. It reduced the footprint by bundling the compute/storage/network into one box. This brought a new set of challenges as the HyperConverged vendors are very focused on their own proprietary building blocks. If you want to scale in a certain way, let’s say you identified a need for more storage and want to add a device that is not sold by the HyperConverged vendor, forget about it...
FinTech is the sum of financial and technology, and it’s one of the fastest growing tech industries. Total global investments in FinTech almost reached $50 billion last year, but there is still a great deal of confusion over what it is and what it means – especially as it applies to retirement. Building financial startups is not simple, but with the right team, technology and an innovative approach it can be an extremely interesting domain to disrupt. FinTech heralds a financial revolution that...
What if you could build a web application that could support true web-scale traffic without having to ever provision or manage a single server? Sounds magical, and it is! In his session at 20th Cloud Expo, Chris Munns, Senior Developer Advocate for Serverless Applications at Amazon Web Services, will show how to build a serverless website that scales automatically using services like AWS Lambda, Amazon API Gateway, and Amazon S3. We will review several frameworks that can help you build serverle...
Most companies are adopting or evaluating container technology - Docker in particular - to speed up application deployment, drive down cost, ease management and make application delivery more flexible overall. As with most new architectures, this dream takes a lot of work to become a reality. Even when you do get your application componentized enough and packaged properly, there are still challenges for DevOps teams to making the shift to continuous delivery and achieving that reduction in cost ...
SYS-CON Events announced today that Loom Systems will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Founded in 2015, Loom Systems delivers an advanced AI solution to predict and prevent problems in the digital business. Loom stands alone in the industry as an AI analysis platform requiring no prior math knowledge from operators, leveraging the existing staff to succeed in the digital era. With offices in S...