CNIC Information System with Pakdata Cf In Pakistan
How to be an expert in Debugging .Net Applications
1. How to become an Expert at Debugging .Net
Application
Karthikeyan VK
Karthik_3030@yahoo.com
@karthik3030
https://blogs.karthikeyanvk.in
2. Enter Text
Why Should you be better @ debugging?
Life is stress free, when we know why the issue occurs.
Life is better, when we know what is causing the issue.
Life becomes easier, when we know how to reproduce the issue.
Good Debugging skills helps us with all the above.
https://blogs.karthikeyanvk.in
3. Enter Text
Mindset of great Debugger
Open Mindset.
Thinking small
Marathon.
Back to Square one - Anytime
Walking Away
https://blogs.karthikeyanvk.in
4. Enter Text
Open Mindset
If your mind is empty, it is always ready for anything, it is open to
everything.
In the beginner's mind there are many possibilities, but in the
expert's mind there are few.
https://blogs.karthikeyanvk.in
5. Enter Text
Open Mindset
No conceived notion.
Leave all your previous knowledge and just approach every
problem as a new problem
Listen to anyone, who has already investigated, don’t reject.
https://blogs.karthikeyanvk.in
6. Enter Text
Thinking Small - Mindset
Try to divide the changes that caused into chunks, in your mind
Divide the problem into smaller junks in your mind.
Brainstorm the smaller junks with your colleague, especially non-
technical person.
https://blogs.karthikeyanvk.in
7. Enter Text
Marathon Mindset
It’s a marathon, Not a sprint.
Specifying any time constraint will only hinder the possibilities
Don’t run into the debugger.
Try to talk through the problem
Read & analyze the code that may have caused the problem
https://blogs.karthikeyanvk.in
8. Enter Text
Marathon Mindset
Make sure you understood the problem before debugging.
If any stakeholder(s) pressures you, try to work out of their sight.
Don’t commit anytime.
https://blogs.karthikeyanvk.in
9. Enter Text
Back to square one -Mindset
Always be ready to ditch all your current investigation.
Learn to start from the scratch, anytime.
Never get into a rabbit hole, always be ready to climb up at any
time.
Make sure your tools helps you go back to square one at any
point of time.
https://blogs.karthikeyanvk.in
10. Enter Text
Walkaway - Mindset
Learn to walk away from debugging.
It can be walking to water cooler for a break.
Going home and having a nice sleep.
Not touching the issue for a day or so.
https://blogs.karthikeyanvk.in
11. Enter Text
Tools for Debugging
Visual Studio – Who can beat this !!
Resharper.
RevDebug.
dotPeek.
dotTrace.
https://blogs.karthikeyanvk.in
12. Enter Text
Why Logging
Good logs helps to travel in time.
Good Logs helps to see the past.
Helps in troubleshooting problem.
Identify infrastructure problem.
Verify our application is working.
https://blogs.karthikeyanvk.in
13. Enter Text
Best Practices - Logging
Don’t reinvent the wheel. Use any logging framework.
Log at proper level – Trace, Debug, Error.
Implement Correlation-id
Easy to read and understand.
Also Write it in a way machine can understand.
User plays: {'user':1334563, 'card':'4 of spade', 'game':23425656}
https://blogs.karthikeyanvk.in
14. Enter Text
Best Practices - Logging
Avoid Vendor Lock-in – Abstract your logging code.
Use side care pattern for logging.
Also think Logging for auditing, statistics and profiling
Never log sensitive data like password etc.
https://blogs.karthikeyanvk.in
15. Enter Text
Why Application Insights
Used to monitor your live applications.
It will automatically detect performance anomalies, and includes
powerful analytics tools to help you diagnose issues and to
understand what users actually do with your app
https://blogs.karthikeyanvk.in
16. Enter Text
Why Application Insights ?
Works for apps on a wide variety of platforms including .NET,
Node.js and Java EE, hosted on-premises, hybrid, or any public
cloud.
Integrates with your DevOps process
https://blogs.karthikeyanvk.in
17. Enter Text
What is Application Insights ?
Application Insights is an extensible Application Performance
Management (APM) service for developers and DevOps
professionals.
https://blogs.karthikeyanvk.in
18. Enter Text
What is Application Insights ?
https://blogs.karthikeyanvk.in
19. Enter Text
What does app insight monitor?
https://blogs.karthikeyanvk.in
Request rates, response times, and failure rates
Dependency rates, response times, and failure rates
Exceptions
Page views and load performance
Custom events and metrics
….
21. Enter Text
Why KQL ?
KQL helps in data-flow model designed to make the syntax easy
to read, author, and automate.
Used to query logs in application insights.
The query uses schema entities that are organized in a hierarchy
similar to SQL's: databases, tables, and columns.
https://blogs.karthikeyanvk.in
22. Enter Text
What is KQL ?
A Kusto query is a read-only request to process data and return
results.
https://blogs.karthikeyanvk.in
24. Enter Text
Why Snapshot Debugger ?
When exception happens snapshot shows the state of source
code and variables at the moment the exception was thrown.
Snapshot Debugger in Azure Application Insights monitors
exception telemetry from your web app / Function app.
https://blogs.karthikeyanvk.in
25. Enter Text
Why Snapshot Debugger ?
It collects snapshots on your top-throwing exceptions so that you
have the information you need to diagnose issues in production.
You can view debug snapshots in the portal to see the call stack
and inspect variables at each call stack frame.
Get access to the variable
https://blogs.karthikeyanvk.in
26. Enter Text
What is Snapshot Debugger ?
Snapshot debugger helps in debugging your application with the
state of source code and variables at the moment the exception
was thrown.
Takes a quick fork and get the copy of process page table.
Will not slow your production while debug.
https://blogs.karthikeyanvk.in
28. Enter Text
Settings to remember
Visual studio 2017 and above
.NET Framework and ASP.NET applications running .NET
Framework 4.5 or later.
.NET Core 2.0 and ASP.NET Core 2.0 applications running on
Windows.
Linux app not supported yet.
https://blogs.karthikeyanvk.in
29. Enter Text
Settings to remember
Access to snapshots is protected by role-based access control
(RBAC). To inspect a snapshot, you must first be added to the
necessary role by a subscription owner.
Make sure you install the extension for Snapshot Debugger
Function app, enable snapshot debugger in host.json
https://blogs.karthikeyanvk.in
31. Enter Text
References
@karthik3030
• https://www.amazon.in/Zen-Mind-Beginners-Shunryu-Suzuki/dp/1590308492
• https://www.jetbrains.com/resharper/features/debugging_assistance.htm
• https://www.scalyr.com/blog/the-10-commandments-of-logging/
• https://docs.microsoft.com/en-us/azure/azure-monitor/app/snapshot-debugger
• https://marketplace.visualstudio.com/items?itemName=ms-
appinsights.appinsightsreleaseannotations
• https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/sqlcheatsheet
https://blogs.karthikeyanvk.in
32. Enter Text
Networking and more
@karthik3030
• https://www.facebook.com/aspiringDotnetArchitects/
• https://www.meetup.com/Chennai-Microsoft-Azure-User-Group/
• https://www.youtube.com/channel/UCJxa58lDcDj4tYQIHh7ORxA
https://blogs.karthikeyanvk.in