.NET (server-side) SDK observability reference

The LaunchDarkly observability features are available for early access

Observability features in the LaunchDarkly UI are publicly available in early access.

The observability SDKs, implemented as plugins for LaunchDarkly server-side and client-side SDKs, are designed for use with the in-app observability features. They are currently available in Early Access, and APIs are subject to change until a 1.x version is released.

If you are interested in participating in the Early Access Program for upcoming observability SDKs, sign up here.

Overview

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.

SDK quick links

LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:

ResourceLocation
SDK API documentationObservability plugin API docs
GitHub repository@launchdarkly/observability-dotnet
Published moduleNuGet

Prerequisites and dependencies

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

Get started

Follow these steps to get started:

Install the plugin

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:

Installation
$dotnet add package LaunchDarkly.ServerSdk
>dotnet add package LaunchDarkly.Observability

Then, import the LaunchDarkly SDK’s namespaces in your application code. The namespace is not the same as the package name:

.NET SDK v8.10+
1using LaunchDarkly.Sdk;
2using LaunchDarkly.Sdk.Server;
3using LaunchDarkly.Observability;

Initialize the client

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:

1var builder = WebApplication.CreateBuilder(args);
2
3var config = Configuration.Builder("sdk-key-123abc")
4 .StartWaitTime(TimeSpan.FromSeconds(5))
5 .Plugins(new PluginConfigurationBuilder()
6 .Add(ObservabilityPlugin.Builder(builder.Services)
7 .WithServiceName("your-service-name")
8 .WithServiceVersion("example-sha")
9 .Build()
10 )
11 ).Build();
12
13var client = new LdClient(config);
14
15// Client must be constructed before the web application.
16var app = builder.Build();

Configure the plugin options

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:

Plugin options, .NET SDK v8.10+
1var plugin = ObservabilityPlugin.Builder()
2 .WithServiceName("example-service")
3 .WithServiceVersion("example-sha")
4 .WithEnvironment("production")
5 .Build("sdk-key-123abc");

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.

Explore supported features

The observability plugins supports the following features. After the SDK and plugins are initialized, you can access these from within your application:

Review observability data in LaunchDarkly

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.