> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# .NET (server-side) SDK observability reference

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

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.

<Note>
  **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:

  <table>
    <thead>
      <tr>
        <th>Resource</th>
        <th>Location</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>SDK API documentation</td>
        <td>[Observability plugin API docs](https://launchdarkly.github.io/observability-sdk/sdk/@launchdarkly/observability-dotnet)</td>
      </tr>

      <tr>
        <td>GitHub repository</td>
        <td>[@launchdarkly/observability-dotnet](https://github.com/launchdarkly/observability-sdk/tree/main/sdk/%40launchdarkly/observability-dotnet)</td>
      </tr>

      <tr>
        <td>Published module</td>
        <td>[NuGet](https://www.nuget.org/packages/LaunchDarkly.Observability/)</td>
      </tr>
    </tbody>
  </table>
</Note>

## Prerequisites and dependencies

This reference guide assumes that you are somewhat familiar with the LaunchDarkly [.NET (server-side) SDK](/docs/sdk/server-side/dotnet).

The observability plugin is compatible with the [.NET (server-side) SDK](/docs/sdk/server-side/dotnet), 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](#install-the-plugin)
* [Initialize the .NET (server-side) SDK client](#initialize-the-client)
* [Configure the plugin options](#configure-the-plugin-options)
* [Explore supported features](#explore-supported-features)
* [Review observability data in LaunchDarkly](#review-observability-data-in-launchdarkly)

## 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:

<CodeGroup>
  ```bash title="Installation" lines wrap theme={null}
    dotnet add package LaunchDarkly.ServerSdk
    dotnet add package LaunchDarkly.Observability
  ```
</CodeGroup>

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

<CodeGroup>
  ```csharp title=".NET SDK v8.10+" lines wrap theme={null}
  using LaunchDarkly.Sdk;
  using LaunchDarkly.Sdk.Server;
  using LaunchDarkly.Observability;
  ```
</CodeGroup>

## 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](/docs/sdk/server-side/dotnet#initialize-the-client) in the .NET (server-side) SDK reference guide.

Here's how to initialize the SDK and plugin:

<CodeGroup>
  ```csharp title="Initialize, .NET SDK v8.10+ with ASP.Net Core" expandable lines wrap theme={null}
  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();
  ```

  ```csharp title="Initialize, .NET SDK v8.10+ .Net Framework and ASP.Net" expandable lines wrap theme={null}
  // In Global.asax.cs
  protected void Application_Start()
  {
    // Other application specific code.
    var client = new LdClient(Configuration.Builder("YOUR_SDK_KEY")
        .StartWaitTime(TimeSpan.FromSeconds(5))
        .Plugins(new PluginConfigurationBuilder().Add(ObservabilityPlugin.Builder()
            .WithServiceName("your-service-name")
            .WithServiceVersion("example-sha")
            .Build()))
        .Build());
  }

  protected void Application_End() {
    Observe.Shutdown();
  }

  // <!-- In Web.config -->
  // <system.webServer>
  //   <!-- Any existing content should remain and the following should be added. -->
  //   <modules>
  //   <add name="TelemetryHttpModule" type="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule,
  //     OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" preCondition="integratedMode,managedHandler" />
  //   </modules>
  // </system.webServer>
  ```
</CodeGroup>

<Note>
  **Network requirements**

  The observability plugin sends data to LaunchDarkly using port 4318 by default. If your network restricts outbound traffic to port 443, read [Network requirements](/docs/sdk/features/observability-config-server-side#network-requirements) to override the OTLP endpoint.
</Note>

## 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:

<CodeGroup>
  ```csharp title="Plugin options, .NET SDK v8.10+" lines wrap theme={null}
  var plugin = ObservabilityPlugin.Builder()
    .WithServiceName("example-service")
    .WithServiceVersion("example-sha")
    .Build("YOUR_SDK_KEY");
  ```
</CodeGroup>

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](/docs/sdk/features/observability-config-server-side).

## Explore supported features

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

* [Configuration for server-side observability](/docs/sdk/features/observability-config-server-side#net-server-side)
* [Errors](/docs/sdk/features/observability-errors#net-server-side)
* [Logs](/docs/sdk/features/observability-logs#net-server-side)
* [Metrics](/docs/sdk/features/observability-metrics#net-server-side)
* [Tracing](/docs/sdk/features/observability-traces#net-server-side)

## 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](/docs/home/observability) and [OpenTelemetry autogenerated metrics](/docs/home/metrics/autogen/opentelemetry).
