Its Saturday 10 am, you wake up and plan to spend your day leisurely. Maybe take a walk outside or watch 1 or 2 movies or go meet couple of your friends.
Next, your phone starts buzzing and yes it’s your boss whose calling you. He is calling you letting you know that something is gone wrong with your e-commerce application. Customer’s are complaining all over your company social media. He needs your help to find out what’s going on. Its now your job now to Detect, Triage, and fix the bug.
What’s your first thought? Gone – another weekend.
Weekdays and Weekends:
How do we make sure what we do on weekdays — don’t breakdown on weekends?
Applications don’t know the difference between weekdays or weekends. They can go down any day or worst anytime. Unfortunately, we cannot stop them from breaking down on weekends. However, we can alteast setup some more tools that will help us during the fires. Say a tool that will alert you before you boss comes to know.
Fortunately, somebody already had same problems and developed tools for everybody. Its called Application Insights.
What is Application Insight?
Application Insights is a Application Performance Management (APM) service from Microsoft Azure.
It is used for applications health monitoring and analytics. Provisioning monitoring and alerting tools is important to gauge and react faster to issues.
Once deployed — Application Insights is constantly looking out for peaks, failures, exceptions, and faults on your behalf. It provides rich visual graphics to easily understand and analyze the collected data.
Say you are working in Microservices architecture for an e-commerce company. Your company generates a Quote, and converts it to a Order. Order is then fulfilled and sent to Shipping. Quote, Order, Product, Customer, Fulfillment, and Shipping are the various departments. Each department services through a Microservices and they all work together to complete an Order.
Now, how would you maintain sanity in such scenarios ?
How will you find out if there is a new bug in your workflow? What if this bug was introduced recently by a another team? What if this team member is in another country? What if it’s a national holiday today? Who do you need to call to fix it? Or would you Download their repository, and start debugging? What is your reaction time? What is your fix? Well, these are the questions in the minds developers when starting to work on issues.
When to setup Application Insights?
ASAP! As soon as we create an application, we can setup App Insights to start capturing data for analytics. More the data, better the analysis.
How Application Insights works?
ASP.Net web applications can install basic libraries from Nuget, and supply the instrumentation key in the web.config. That’s it. Instrumentation will automatically start running, and upload telemetry data to Azure services.
This data is available (per setup) in Azure portal. You can analyze data in tables or charts. All conveniently facilitated in one central place.
Infact the code that runs outside of Azure will still do telemetry upload — not necessarily in Azure.
What does Application Insights exactly Monitor?
Everything! Pretty much everything you want it to monitor.
- Http Requests & Responses:
- How many requests were successful, and
- How many failed.
- Why they failed.
- When they failed.
- Dependency calls.
- How many SQL Server calls.
- What may be the exceptions from SQL server etc.
- Server Exceptions.
- What exceptions were thrown by your application.
- Which class.
- Which method.
- Which line.
- What exception.
- What time.
- How many times this exception happened.
- Page views.
- How many views per page.
- Highest viewed page.
- Slowest loading page.
- Performance counters.
- Server CPU usage.
- Server RAM usage.
- Server storage usage.
- User session counts.
- How many users are currently logged.
- How many failed login.
- Custom events.
- Custom metrics through code.
- Like how many orders processed.
- How many still processing.
- How many payment confirmed.
- How many fulfilled.
- How many shipped.
Application Insight is also a analytics engine that can learn the behavior of code and suggest changes. Like Application Insights can suggest Indexes on SQL Server tables based on queries we run.
You can analyze the usage patterns for resources and pages from App Insights. Like how many people are currently logged into a website. How many times a particular page was viewed. How many web api requests return 500 http status code. Best of all, you can setup custom alerts for these metrics.
What if we could catch a bug before our prestigious customer notices it?
What if we could scale up out applications before our website starts slowing down?
Such pro-active measures can help us improve credibility with customers. It will also lessen embarrassment for management. Looking out for changes in behavior pre and post deployments will reduce the severity of damages – if any.
When is as important as How you detect an issue.
How many times have you reported a bug without evidence? None.
Especially in Web API world — bugs are considered rumors if you don’t provide evidence (payload).
Payloads lets team to identify, and reproduce a bug. Without payload, they have simulate the bug using production data elsewhere. Every team is busy working for their sprint. Without payload, they won’t investigate bugs and provision your request. You are bound to provide evidence as much as the detection itself.
Application Insights can be setup to save incoming and outgoing requests — especially the failed ones. You can pull payload from logs and send out to the responsible team. That’s it — now it is a someone else problem. Defects can be triaged accordingly.
In conclusion, to serve our customers well we should also give importance to building dev tools around the actual system. Doing so, will help developers react faster to catastrophic failures and indirectly improving the customer experience.