• 0

Code Level Runtime Analytics


Go to solution Solved by DevTech,

Question

wrack

Hi,

 

Being given a task to analyse and collect info on all code paths for a very very large monolithic .NET Web app that is used across various clients.

 

Thinking about adding in some reflection type code that basically collects data of run-time code path taken depending on the params passed to various methods.

 

Once I have the data, need to start removing/deprecating code that never gets used in few months in real world. Along with refactoring and adding more test coverage on major code paths to improve quality.

 

I am aware of unit testing approach but this app is 13+ years old and unit testing can't be just added, can't be easily refactored without breaking something, can't be easily re-written.

 

Are there any tools frameworks that can be integrated into existing code that would allow me to collect such data?

 

Not looking for code samples but if anyone has it then awesome. Any help, general guidance, software/framework recommendation would be highly appreciated.

 

Something like Google Analytics but for the actual source code itself.

 

TA :)

Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0
DevTech
9 hours ago, wrack said:

Hi,

 

Being given a task to analyse and collect info on all code paths for a very very large monolithic .NET Web app that is used across various clients.

 

Thinking about adding in some reflection type code that basically collects data of run-time code path taken depending on the params passed to various methods.

 

Once I have the data, need to start removing/deprecating code that never gets used in few months in real world. Along with refactoring and adding more test coverage on major code paths to improve quality.

 

I am aware of unit testing approach but this app is 13+ years old and unit testing can't be just added, can't be easily refactored without breaking something, can't be easily re-written.

 

Are there any tools frameworks that can be integrated into existing code that would allow me to collect such data?

 

Not looking for code samples but if anyone has it then awesome. Any help, general guidance, software/framework recommendation would be highly appreciated.

 

Something like Google Analytics but for the actual source code itself.

 

TA :)

Plain old code profiling/analysis is a popular tool category since the dawn of .NET but to some extent, Roslyn has sparked a modern revolution in many .NET Tools.

 

1. Unit testing has NOTHING to do with any aspect of this

 

2. nanoRant: Constant Continuous Code Refactoring was the real useful business "take-away"  from Extreme Programming, not unit testing which is mostly a sick joke in the currently common watered down weak descendant of Extreme Programming techniques.

 

2. You can use AOP to instrument any large bodies of existing code. https://www.postsharp.net/aop.net

 

3. .NET has the most advanced compiler on Planet Earth in the form of Roslyn, so any tool that uses the code understanding features of Roslyn should be given a preference.

 

https://github.com/dotnet/roslyn

 

4. Here are a few starting points for you:

 

https://github.com/mre/awesome-static-analysis

 

https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis

 

https://www.owasp.org/index.php/Source_Code_Analysis_Tools

 

https://visualstudiomagazine.com/articles/2018/05/01/vs-analysis-tools.aspx

 

https://www.sonarsource.com/products/codeanalyzers/sonarcsharp.html

https://github.com/SonarSource/sonar-dotnet

 

https://www.ndepend.com

 

 

  • Thanks 1
Link to post
Share on other sites
  • 0
wrack

Thank you. You are spot on on many things and the mess I have is inherited so very little I can do on unit test, continuous code refactoring etc.. Initiatives are also inherited so have no choice but to investigate the possibilities.

 

Let me tell you the most important out come I am after. There are a lot of QA issues and they only appear on UAT or even worse, post deployment :( What I am trying to achieve is find out the most hit areas of the code for different configurations (client configurations) and then get out QA teams to hit those areas as hard they can to sort out QA issues. In a long run the whole thing is going to be re-written but that would be few years and  I need results in 3-4 months.

 

So that said, I am actually looking for run-time recording and then analysis of method calls and parameter values so I can then generate a heat map for each client configuration and then work with QA team. Hopefully this gives a little more context.

Link to post
Share on other sites
  • 0
DevTech
57 minutes ago, wrack said:

Thank you. You are spot on on many things and the mess I have is inherited so very little I can do on unit test, continuous code refactoring etc.. Initiatives are also inherited so have no choice but to investigate the possibilities.

 

Let me tell you the most important out come I am after. There are a lot of QA issues and they only appear on UAT or even worse, post deployment :( What I am trying to achieve is find out the most hit areas of the code for different configurations (client configurations) and then get out QA teams to hit those areas as hard they can to sort out QA issues. In a long run the whole thing is going to be re-written but that would be few years and  I need results in 3-4 months.

 

So that said, I am actually looking for run-time recording and then analysis of method calls and parameter values so I can then generate a heat map for each client configuration and then work with QA team. Hopefully this gives a little more context.

Oh, that's simple then, just plain old Visual Studio 2019 stuff...

 

Dynamic tracing of executing code is a standard well tested and very useful feature of Visual Studio 2019

 

https://azuredevopslabs.com/labs/devopsserver/intellitrace/

 

Also useful to your area:

 

https://azuredevopslabs.com/labs/devopsserver/codeanalysis/

 

https://azuredevopslabs.com/labs/devopsserver/intellitest/

 

https://azuredevopslabs.com/labs/devopsserver/liveunittesting/

 

https://azuredevopslabs.com/labs/devopsserver/livedependencyvalidation/

 

https://azuredevopslabs.com/labs/devopsserver/releasemanagement/

 

 

 

 

  • Like 1
Link to post
Share on other sites
  • 0
DevTech

As a general observation, you seem to be describing a very large scale retrofit of running code with instrumentation payloads and re-architecture best introduced in a green field scenario.

 

Your system then becomes a high risk for Heisenbugs which can lead to a nightmare of "ring around the rosies"

 

https://en.wikipedia.org/wiki/Heisenbug

 

  • Like 2
Link to post
Share on other sites
  • 0
wrack
16 hours ago, DevTech said:

Oh, that's simple then, just plain old Visual Studio 2019 stuff...

 

We are still on VS2013. Have secured enterprise agreement to get VS2019 and few selected people have got it including myself but wide scale deployment is few months away.

 

Speaking to a senior architect said we have used New Relic before with amazing success but with financial system and our company's stance on not using Cloud tech (just yet) ruled the use of New Relic. We are in process of getting that ban reviewed.

16 hours ago, DevTech said:

As a general observation, you seem to be describing a very large scale retrofit of running code with instrumentation payloads and re-architecture best introduced in a green field scenario.

 

Another reason I am collecting the data is to identify heavy hitters and address QA issues with extensive test coverage (not unit but end to end scenario based) using our automated regression system.

 

Thank you for your help and guidance on this. Much appreciate it.

Link to post
Share on other sites
  • 0
DevTech
1 hour ago, wrack said:

We are still on VS2013. Have secured enterprise agreement to get VS2019 and few selected people have got it including myself but wide scale deployment is few months away.

 

Speaking to a senior architect said we have used New Relic before with amazing success but with financial system and our company's stance on not using Cloud tech (just yet) ruled the use of New Relic. We are in process of getting that ban reviewed.

Another reason I am collecting the data is to identify heavy hitters and address QA issues with extensive test coverage (not unit but end to end scenario based) using our automated regression system.

 

Thank you for your help and guidance on this. Much appreciate it.

Well obviously my thoughts have been very generic, but have a small useful attribute (maybe) of being an "outside viewpoint"

 

Each one of your replies drops an extra hint of a legacy system of very large size and complexity for which you deserve extra credit in seeking all viewpoints and ideas in your eval process.

 

So in that spirit, and to be complete as well in the spirit of excellent standard of due diligence you are exhibiting, I will point out a HUGE sea change in the design, architecture, deployment and real time delivery of modern enterprise (and anything large) applications to users and that is the Kubernetes revolution. At this point EVERY enterprise player has signed on to this architecture and it has arrived and will be considered as mandatory dial tone infrastructure within a few years, if not right now.

 

I point this out in your case because any establishment using wonderful .NET technology may have missed some of the signals and messaging around this architecture since on first glance it seems to be about some stuff a bit distant to .NET platforms, "Cloud" and Linux. Even if it is not possible to shoehorn a legacy system into the new way of doing things, there may be opportunities to build in compatibilities as you go along...

 

The standards around this architecture is run by the CNCF (Cloud Native Computing Foundation) (part of the Linux Foundation) and it can easily be missed that it describes the future of Enterprise Computing BOTH for Cloud and On-Premise and ALSO both for Linux and for Windows. Microsoft is a PRIMARY member of this foundation. There is no restriction on following a CNCF standard on local servers and with Windows technology. In fact some of the tech is already baked right into the Windows API.

 

Skipping all the crap in between, the beautiful result of twisting application architecture into many Docker Containers managed by Kubernetes is that the application becomes robust, scalable, hot deployable and most importantly for enterprise, Self Healing with zero downtime. Kubernetes manages the life cycle and moves containers around as needed by resource requirements, best fit, and demand loading. All the infrastructure is free OSS, can run on local servers and dev machines (well beefy ones...) and once working, scales with zero or little effort to larger local clusters or the Cloud since it is a standard supported by every Cloud provider.

 

The downside is a bit of head scratching to understand where to store state when the application containers are stateless (only way to get self-healing) and how to talk to your application when Kubernetes might have moved it anywhere!

 

Windows 10 and the latest Windows Server has native code built into the Windows API to support both native Windows Containers and Linux Containers. The latest version of .NET Core thrives in this flexible cross platform ubiquitous environment.

 

https://www.cncf.io

https://www.cncf.io/about/members/

https://landscape.cncf.io

https://www.docker.com/products/windows-containers

 

Windows Containers on Windows 10

https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-10

 

Linux Containers on Windows 10

https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-10-linux

 

 

CNCF_TrailMap_latest.png

CNCF_TrailMap_reduced.png

Link to post
Share on other sites
  • 0
wrack

Thank you again.

 

For the eventual rewrite MicroServices, Docker, Event Sourcing, CQRS, Snapshot DB etc, all avenues are being considered but that is for the chief architect to take care.

 

For the moment my focus is elsewhere.

Link to post
Share on other sites
  • 0
DevTech

Hey I'm sure that will work out well for you. Best wishes there...

 

If you want as you go along, feel free to throw out thoughts, inquiries, etc  - micro or macro...

 

A Note for other readers:

 

Something like a snapshot of a system or a database is very primitive compared to Container Self-Healing which is a kind of quantum leap first step towards a Holy Grail of computing. It works. It has not beaten down the doors of anyone's attention since it can be seen as "limited" in that it needs major changes to the architecture of things. It is a remarkable by-product of Docker Containers being stateless where an entire application image becomes the (huge) equivalent of a stateless HTTP request.

 

Normal stuff you expect in your VM server world that is missing in zillions of amorphous clusters of Dockers:

 

1. You need a Service Mesh to locate and talk to your App:

(your App moves around, changes IP address, adds copies of itself on demand load, etc)

 

Examples of CNCF Solutions:

https://linkerd.io  https://github.com/linkerd/linkerd2

https://www.getambassador.io  https://github.com/datawire/ambassador

https://www.envoyproxy.io   https://github.com/envoyproxy/envoy

https://traefik.io  https://github.com/containous/traefik

 

2. You most likely will need a file system composed of specialized Containers:

(your App can be destroyed, moved etc so like a HTTP request nothing is retained locally)

 

Examples of CNCF Solutions:

https://rook.io   https://github.com/rook/rook

https://www.openebs.io  https://github.com/openebs/openebs

https://min.io  https://github.com/minio/minio

 

3. You will need State management

 

- can be as simple as using Container Native Storage (#2 above)

- or a DB (ideally a CNCF standards compliant DB)

- or a "Serverless" API

 

but #3 is a more complex subject for another day...

 

But also, for once, the complexity ends up yielding a very real simplicity which is why Google, who invented Kubernetes is running BILLIONS of containers every day!

 

https://kubernetes.io

https://azure.microsoft.com/en-ca/services/kubernetes-service/

https://en.wikipedia.org/wiki/Kubernetes

 

 

  • Thanks 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Ather Fawaz
      Half is a new binary floating-point type in .NET 5 Preview 7 to speed up ML workflows
      by Ather Fawaz

      In .NET 5 Preview 7, Microsoft has now introduced another floating-point datatype alongside the standard Float and Double. Dubbed Half, the new datatype is equivalent to binary16, which is specified in the IEEE 754 standard for floating-point arithmetic.

      Unlike Float and Double in C#, which occupy 32 bits and 64 bits respectively, Half will be based on 16 bits. These bits will be split as follows: one sign bit, five exponent bits, and 10 mantissa bits. Taken together, Half can represent and store values in the range ±65504. This decrease in precision is where the datatype gets its name from in the first place. One rather strange implication of this format is that a Half can store both positive zero and negative zero:

      1 00000 0000000000 = -0 0 00000 0000000000 = +0 Computations in machine learning take advantage of the decreased precision to speed up calculations and cut down on storage space. So, this would probably be the primary use case for a Half. Furthermore, you will be able to store a Half using a Float or Double, but the inverse won't be true without a loss of precision since you will be transitioning to lesser bits. Moreover, it is to be noted that:

      It is expected that the Half will find its way into many codebases and will soon be supported in C# as a half datatype as it promises faster computation and efficiency in ML workflows. Further details can be found here.

    • By Sszecret
      Here are the Azure dev tools announcements from this year's Build conference
      by Florin Bodnarescu



      Moving on from database, cognitive services, and infrastructure news, we should also touch on the Azure developer tool announcements from this year’s virtual Build event.

      .NET 5, ASP.NET and more

      The biggest news surrounding .NET 5 is that Preview 4 is now available – more info here -, and that general availability is coming in November. The new version will continue the unification of the .NET platform across devices and workloads, with smaller, faster single file EXEs that use less memory, and are thus appropriate for microservices and containerized apps. All workloads will eventually be supported.

      On a related note, Microsoft also announced and provided a demonstration of .NET Multi-platform App UI (.NET MAUI), which enables developers to build apps for any device via a single codebase and project system. An evolution of Xamarin.Forms, .NET MAUI will be part of the unified .NET “in the .NET 6 time frame” with previews set to be available by the end of this year.

      Another developer-friendly announcement relates to ASP.NET Blazor – which enables devs to create interactive web UIs using C# instead of JavaScript -, and more specifically its support for WebAssembly. This translates into the compiled applications running faster and consuming less memory compared to their JavaScript equivalents. Go to this link for more info.

      Other Azure services

      For JavaScript devs that are building static or “single page” web apps, there’s now a public preview of the Static Web Apps hosting option in Azure App Service. What this allows you to do is use the JAMstack pattern and point to source code in a GitHub repository, and orchestrate the relevant services needed much quicker than before.

      On the Azure Kubernetes Service (AKS) side of the fence, there’s now support for Windows Server containers, private clusters via Azure Private Link and integration with Azure Advisor for improved security and performance.

      Visual Studio

      Moving on to Visual Studio, the Live Share feature – which enables co-editing and debugging in real time – now has support for text and voice chat, in addition to sharing of running apps. All of these features are now in public preview.

      Visual Studio Codespaces (previously Visual Studio Online) now has support for a new preview instance type, and the pricing has been lowered for all instance times. Codespaces is additionally available in GitHub as a private preview.

      GitHub

      Available in beta as part of GitHub Advanced Security, there’s now code scanning and secret scanning – free for public repos. Secret scanning (previously token scanning) has been available for public repositories since 2018, but it is now available for private repositories too. It’s put in place to prevent unauthorized access and it watches for known secret formats, immediately notifying developers of its findings.

      For those using both GitHub and Azure, there’s now a set of GitHub Actions for Azure – in excess of 30 – which are integrated into VS Code, Azure CLI, and the Azure Portal to simplify the creation of workflows for building, testing, packaging and deploying to Azure.

      As an addition to all of this, the GitHub Discussions forum is now in public beta, allowing folks to talk about various GitHub related things, talks which were previously only possible under pull requests and issues.

      The last bit of developer-centric news for Azure is Microsoft’s release of a Developer Velocity Assessment tool to measure a DVI (Developer Velocity Index). For those not familiar, Developer Velocity is basically a new term for developer productivity as it relates to business performance.

    • By News Staff
      This Complete .NET & C# Developer Certification Bundle only costs $31
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where for only a limited time you can save 98% off the Complete .NET & C# Developer Certification Bundle. A comprehensive, 58-hour guide to becoming a professional-quality software developer.



      What's the deal?
      This bundle contains the following courses:

      Software Architecture: Meta & SOLID Principles in C#
      Develop Software Systems Applying Design Patterns Based on Meta & SOLID Principles Learn Unit Testing with NUnit and C#
      Learn Unit Testing, TDD, Mocking & Dependency Injection Software Architecture: Dependency Injection for C# Developers
      Learn Dependency Injection Techniques TDD in C# From A to Z
      Learn Test-Driven Development & Improve You Unit Testing Skills Software Architecture: Functional Programming in C#
      Learn the Principles of Functional Programming Apply Them to Improve Software Architecture Master the Art of Writing Clean Code in C#
      Learn How to Write Clean & Maintainable Code in C# C# in Depth: Puzzles, Gotchas, Questions at Interviews
      Discover C# Tips & Interview Traps Complete Practical LINQ Tutorial for C# Developers
      Cover All Things LINQ Automate Applications with SpecFlow and Selenium WebDriver in C#
      Cover Behavior-Driven Development with SpecFlow & Selenium WebDriver with C# Algorithms & Data Structures in C#: Complete Tutorial
      Learn Data Structures & Algorithms in C# from A to Z Good to know
      Length of time users can access courses: Lifetime Certification of completion included Redemption deadline: redeem your code within 30 days of purchase For full details, terms, and instructor info for the above courses, click here.

      What's the benefit?
      This save 98% off the Complete .NET & C# Developer Certification Bundle normally costs $2,000, but you can pick it up for just $31 for a limited time, that's a saving of 98% ($1,969) off the normal price!

      >> Get this deal, or learn more about it here <<
      See all discounted Online Courses on offer. This is a time-limited deal.

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      Check out our recent deals here or on the Neowin Deals site. For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerce's own determination of retail pricing.

    • By Geek@work
      Hello everyone,
       
      Since updating .Net to 4.8 my Print Management is throwing a Script error. Line 44 Char 22: Unspecified Error. Also i'm having issues with Exchange 2010 Management Console. I was able to fix that by calling the console from a batch with compatibility features.
      No matter what i try for Print Management i can't get it to work. I can't find this issue online. Other than articles from 2010, 2009, etc.
      Any insight is much appreciated.
       
      OS build is 18362.329. Not an insider.
       
      Thanks
       


    • By News Staff
      This Complete .NET & C# Developer Certification Bundle is now 98% off
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where for only a limited time you can save 98% off the Complete .NET & C# Developer Certification Bundle. A comprehensive, 58-hour guide to becoming a professional-quality software developer.



      What's the deal?
      This bundle contains the following courses:

      Software Architecture: Meta & SOLID Principles in C#
      Develop Software Systems Applying Design Patterns Based on Meta & SOLID Principles Learn Unit Testing with NUnit and C#
      Learn Unit Testing, TDD, Mocking & Dependency Injection Software Architecture: Dependency Injection for C# Developers
      Learn Dependency Injection Techniques TDD in C# From A to Z
      Learn Test-Driven Development & Improve You Unit Testing Skills Software Architecture: Functional Programming in C#
      Learn the Principles of Functional Programming Apply Them to Improve Software Architecture Master the Art of Writing Clean Code in C#
      Learn How to Write Clean & Maintainable Code in C# C# in Depth: Puzzles, Gotchas, Questions at Interviews
      Discover C# Tips & Interview Traps Complete Practical LINQ Tutorial for C# Developers
      Cover All Things LINQ Automate Applications with SpecFlow and Selenium WebDriver in C#
      Cover Behavior-Driven Development with SpecFlow & Selenium WebDriver with C# Algorithms & Data Structures in C#: Complete Tutorial
      Learn Data Structures & Algorithms in C# from A to Z Good to know
      Length of time users can access courses: Lifetime Certification of completion included Redemption deadline: redeem your code within 30 days of purchase For full details, terms, and instructor info for the above courses, click here.

      What's the benefit?
      This save 98% off the Complete .NET & C# Developer Certification Bundle normally costs $2,000, but you can pick it up for just $31 for a limited time, that's a saving of 98% ($1,969) off the normal price!

      >> Get this deal, or learn more about it here <<
      See all discounted Online Courses on offer. This is a time-limited deal.

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      Check out our recent deals here or on the Neowin Deals site. For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software for Private Internet Access and NordVPN deals.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerce's own determination of retail pricing.