This folder contains a .NET solution SignalFx.Tracing.Samples.sln with the following example projects:
- Azure.Functions
- OpenTracing.Manually.Instrumented.Library
- SignalFx.OpenTracing.Manually.Instrumented.App
These projects demonstrates how to use the SignalFx.Tracing.OpenTracing and the OpenTracing NuGet packages to manually instrument .NET applications and libraries.
- The manual instrumentation code should use only OpenTracing constructs. The benefit of this approach is that if later, the application is deployed with auto-instrumentation enabled traces will keep the manually added spans and will be enriched with more spans added by the auto-instrumentation.
- Use the OpenTracing semantic conventions
especially use the
error
tag with valuetrue
in case of exceptions and errors. - Libraries should use only constructs from OpenTracing and don't need to directly reference the SignalFx.Tracing.OpenTracing NuGet Package.
- Applications need to reference
SignalFx.Tracing.Tracer.Instance
to ensure that the Tracer runs the auto-configuration and registers itself as theOpenTracing.Utils.GlobalTrace.Instance
. Example:
internal static class Program
{
internal static void Main(string[] args)
{
var signalFxTracer = Tracer.Instance;
signalFxTracer.Settings.ServiceName = "OpenTracing.Manually.Instrumented.App";
using var instrumentedSample = new InstrumentedSample();
instrumentedSample.Start();
Console.WriteLine("Sample is running on the background, press ENTER to stop");
Console.ReadLine();
Console.WriteLine("Shutting down...");
}
}