Docs » µAPM Instrumentation Guide » Send Traces From a .NET Application to SignalFx

Send Traces From a .NET Application to SignalFx 🔗

Important

The original µAPM product, released in 2019, is now called µAPM Previous Generation (µAPM PG). In the documentation, µAPM now refers to the product released on March 31, 2020.

If you are using µAPM Previous Generation (µAPM PG), see µAPM PG Instrumentation Guide.

Automatically instrument a .NET application to capture and send traces to SignalFx with the SignalFx Tracing Library for .NET. The SignalFx Tracing Library for .NET uses OpenTracing API 2.0 to instrument a .NET application. To set up instrumentation, see the SignalFx Tracing Library for .NET on GitHub.

The SignalFx Tracing library for .NET supports .NET Core 2.0+ on Linux and Windows and .NET Framework 4.5+ on Windows. All instrumentations are in beta.

Configure the SignalFx Tracing Library for .NET to send traces to a Smart Agent. The Smart Agent forwards data to a µAPM ingest endpoint in SignalFx. Configure the Smart Agent to add tags to identify spans that belong to specific hosts or microservices. If you want to configure instrumentation for a .NET application and can’t deploy a Smart Agent, you can configure the SignalFx Tracing Library for .NET to send traces directly to an OpenTelemetry Collector or µAPM ingest endpoint in SignalFx instead. For more information about deploying a Smart Agent, see Installing the SignalFx Smart Agent.

Optionally, deploy an OpenTelemetry Collector between a Smart Agent or instrumented code and the µAPM ingest endpoint. The OpenTelemetry Collector supports protocols the Smart Agent doesn’t support and allows for larger retry buffers to prevent packet loss. For more information about deploying an OpenTelemetry Collector for µAPM, see Deploy an OpenTelemetry Collector for SignalFx µAPM.

The SignalFx Tracing library for .NET uses the Common Language Runtime’s (CLR) profiling API to instrument the Intermediate Language (IL) of supported libraries and frameworks. Install the utility with your system package manager after downloading the latest release of the SignalFx Tracing Library for .NET on GitHub.

The SignalFx Tracing library for .NET doesn’t require direct code modification or additional dependencies for the CLR profiler. Instead, it provides an environment configuration that instructs child CLR processes to augment internal client and application functionality to report traced behavior to µAPM.

Add custom instrumentation to a .NET application 🔗

Build on the provided tracing functionality by modifying and adding to generated traces. The tracing insights the SignalFx Tracing Library for .NET provides can be the foundation of any elements you add later. Capture a more detailed representation of the logic and functionality of your application, clients, and framework by adding to the instrumentation the library already provides.

The SignalFx Tracing library for .NET provides and registers an OpenTracing-compatible global tracer you can use like this:

using OpenTracing;
using OpenTracing.Util;

namespace MyProject
{
    public class MyClass
    {
        public static void MyMethod()
        {
            // Obtain the automatically registered OpenTracing.Util.GlobalTracer instance
            var tracer = GlobalTracer.Instance;

            // Create an active span that will be automatically parented by any existing span in this context
            using (IScope scope = tracer.BuildSpan("MyTracedFunctionality").StartActive(finishSpanOnDispose: true))
            {
                var span = scope.Span;
                span.SetTag("MyImportantTag", "MyImportantValue");
                span.Log("My Important Log Statement");

                var ret = await MyAppFunctionality();

                span.SetTag("FunctionalityReturned", ret.ToString());
            }
        }
    }
}