This topic documents how to get started with the LaunchDarkly observability plugin for the .NET (server-side) SDK.The .NET (server-side) SDK supports the observability plugin for error monitoring, logging, and tracing.
LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
This reference guide assumes that you are somewhat familiar with the LaunchDarkly .NET (server-side) SDK.The observability plugin is compatible with the .NET (server-side) SDK, version 8.10 and later.This plugin is designed for use with ASP.Net Core or ASP.Net:
When using .NET or netstandard2.0, the plugin works with ASP.Net Core
When using .NET Framework, the plugin works with ASP.Net
LaunchDarkly uses a plugin to the .NET (server-side) SDK to provide observability.The first step is to make both the SDK and the observability plugin available as dependencies.Here’s how:
Next, initialize the SDK and the plugin.To initialize, you need your LaunchDarkly environment’s SDK key. This authorizes your application to connect to a particular environment within LaunchDarkly. To learn more, read Initialize the client in the .NET (server-side) SDK reference guide.Here’s how to initialize the SDK and plugin:
var builder = WebApplication.CreateBuilder(args); var config = Configuration.Builder("YOUR_SDK_KEY") .StartWaitTime(TimeSpan.FromSeconds(5)) .Plugins(new PluginConfigurationBuilder() .Add(ObservabilityPlugin.Builder(builder.Services) .WithServiceName("your-service-name") .WithServiceVersion("example-sha") .Build() ) ).Build(); var client = new LdClient(config); // Client must be constructed before the web application. var app = builder.Build();
You can configure options for the observability plugin when you initialize the SDK. The plugin constructor takes an optional object with the configuration details.Here is an example:
var plugin = ObservabilityPlugin.Builder() .WithServiceName("example-service") .WithServiceVersion("example-sha") .Build("YOUR_SDK_KEY");
For more information on plugin options, as well as how they interact with environment variables and existing OpenTelemetry configuration, read Configuration for server-side observability.
The observability plugin supports the following features. After the SDK and plugins are initialized, you can access these from within your application:
After you initialize the SDK and observability plugin, your application automatically starts sending observability data back to LaunchDarkly in the form of custom events. You can review this information in the LaunchDarkly user interface. To learn how, read Observability and Metrics autogenerated from OpenTelemetry data.