Manually instrument .NET applications for Splunk Observability Cloud
Manually instrument your .NET application to add custom attributes to spans or manually generate spans.
Note: The SignalFx Instrumentation for .NET is deprecated as of February 21, 2024 and will reach End of Support on February 21, 2025. Until then, only critical security fixes and bug fixes will be provided. After the date, the library will be archived and no longer maintained. New customers instrumenting the .NET ecosystem should use the
The SignalFx Instrumentation for .NET provides and registers an OpenTracing-compatible global tracer that you can use to instrument your applications manually for Splunk Observability Cloud. You can use custom or manual instrumentation when you need to add custom attributes to spans, or if you need to generate spans manually.
Splunk Distribution of OpenTelemetry .NET
. Existing customers should consider migrating to Splunk Distribution of OpenTelemetry .NET which offers similar capabilities. To learn how to migrate, see Migrate from the SignalFx .NET Instrumentation
Note: The SignalFx Instrumentation for .NET supports OpenTracing version 0.12.1 and higher.
To instrument your .NET application manually, follow these steps:
-
Add the OpenTracing dependency to your project:
XML<PackageReference Include="OpenTracing" Version="0.12.1" /> -
Obtain the
OpenTracing.Util.GlobalTracerinstance and create spans:CSHARPusing OpenTracing; using OpenTracing.Util; namespace MyProject { public class MyClass { public static async void MyMethod() { // Obtain the automatically registered OpenTracing.Util.GlobalTracer instance var tracer = GlobalTracer.Instance; // Create an active span that automatically becomes a child span of any existing span in this context using (IScope scope = tracer.BuildSpan("MyTracedFunctionality").StartActive(finishSpanOnDispose: true)) { var span = scope.Span; span.SetTag("MyTag", "MyValue"); span.Log("My Log Statement"); var ret = await MyAppFunctionality(); span.SetTag("FunctionalityReturned", ret.ToString()); } } } }