Instana introduces automatic distributed tracing of .NET Core

Instana is pleased to announce our beta program for automatic distributed tracing of .NET core applications on Windows and Linux.

Microsoft Goes Open Source with .NET Core

With the introduction of .NET Core, the .NET community experienced one of the biggest shifts since its initial release in 2002. Launched as an open-source project, the complete source-code is available on GitHub, allowing anybody to participate by reviewing, forking or contributing to the project. This paradigm-shift drew quite a bit of attention throughout the whole developer-community (not only .NET veterans!).

The beneficial contributions from the community and the enormous effort everybody put into making the platform better day by day, has led to .NET Core being one of the most modern development-stacks around – and the work is not done yet! The developers focused on making .NET Core a natural fit for modern, web-scale, microservice-based, containerized applications, providing a solid runtime to not only run on Windows, but on Linux as well.

C# is one of the most popular languages according to the TIOBE index. There is a lot of talent out there being able to leverage both, the modern and well-designed languages like C# and F# and the modern runtime environment making up .NET Core.

A lot of projects are transitioning from .NET Classic to .NET Core and are preparing their applications for modern stacks. This enables them to choose from a large variety of deployment options.

But with power comes responsibility. There has to be means of getting information not only on what happens inside all those small, focused services (i.e., how they behave or how they scale), but also what goes wrong or could be optimized. This is where all the automated distributed application tracing by Instana (be it .NET Classic, Java, PHP, Python, Ruby, Node… you name it) comes into play. Instana offers automatic tracing for .NET Core – on any OS – just like all other platforms. Just install the agent and you’re ready to go.

Technical Details of Instana .NET Core Monitoring

Our .NET Core offering uses the same mechanics and semantics as the one for .NET Classic does. It will rewrite portions of the code prior to the CoreCLR executing it. Preparing and executing tracing is a matter of multiple components, as you can see in the picture below.

NET-Core-monitoring-il-rewriter

So how does the IL-Rewriter know, what to instrument?

For providing that information, we give a list of hints to our IL-rewriter, telling it what and where to instrument. The IL-rewriter will inspect any assembly being loaded into the AppDomain and search for matching methods to be instrumented. The instrumentation always follows the same principal:

  • Call into our managed-tracer when entering a method
  • Call into our managed-tracer when leaving a method

Under most circumstances an entry/exit-pair like this will create a span in a trace. There are a few exceptions, however, when instrumentation is a little bit more complicated. Afterwards the managed tracer will apply a strategy for data-extraction to the call, based on what type is being instrumented, which method has been called, and which arguments are present. This data-extraction process is responsible for what data you will see in a span.

Currently, we support automatic tracing for the following technologies:

  • Entries
    • ASP.NET Core requests
  • Exits
    • HttpClient
    • HttpWebRequest
    • ADO
    • ILogger logging framework

And we’re constantly adding instrumentable packages to our list. If you feel like you definitely need something specific to be instrumented, to have Instana’s distributed tracing add value for you, just let us know!

Distributed Tracing with .NET Core

As with all of our other tracers for different platforms and runtimes, the .NET Core Tracer is no exception when it comes to supporting correlation of distributed calls across your application’s services. Distributed traces are stitched together by adding correlation information when an outgoing call happens and extracting that information on the receiver’s site, creating a continuous logic flow throughout all of the components being touched as part of any given transaction.

Of course, this is not limited to .NET Core. In a polyglot application landscape, control-flow goes from one environment to another, involving several runtimes or service categories. This is why all of our tracers implement the same way of correlating traces. This gives you a holistic view on a call, no matter which languages and platforms make up the transaction flow.

Installation and Configuration of Instana .NET Core Monitoring

Our aim is to reduce the need for our customers to configure anything or to even change code. So once the tracing for .NET Core is enabled in your agent, you should be good to go. We’re still working hard on streamlining the process to provide a zero-configuration capability for instrumentation of any .NET application. As of yet there is one small change to integrate when starting your apps, but that’s it. Just execute the shell-script provided by the agent before you run your own application. This script will take care of making everything available for your software to be traced, no need to worry about paths and versions.

New to .NET Core tracing, is that it will work in any containerized environment, fully transparently. To have the tracer available inside the container when the process starts up, just add our nuget-package to your app and apply some minor changes to your docker file. After having done that, simply rebuild your container and get traces from your .NET Core application inside the container. The Nuget package has not yet been released officially. If you are interested in trying it out, just let us know and we’ll provide it.

Our tracer is compiled against .NET Standard 2.0. This allows us to be compatible with any upcoming release of .NET Core – but not with versions of .NET Core older than 2.0. Only with that release can we be sure to have all the tools we need in a reliable and stable version.

So if you’re still running apps on versions prior to 2.0, migrate them 🙂

If you’re already an Instana customer and you want to be part of the .NET Core beta program you should contact your Instana representative immediately.