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

# Python SDK observability reference

> This topic documents how to get started with the LaunchDarkly observability plugin for the Python SDK.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

## Overview

This topic documents how to get started with the LaunchDarkly observability plugin for the Python SDK.

The Python SDK supports the **observability plugin** for error monitoring, logging, and tracing.

<Note title="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:
</Note>

| Resource | Location |
| - | - |
| SDK API documentation | [Observability plugin API docs](https://launchdarkly.github.io/observability-sdk/sdk/@launchdarkly/observability-python/) |
| GitHub repository | [@launchdarkly/observability-python](https://github.com/launchdarkly/observability-sdk/tree/main/sdk/%40launchdarkly/observability-python) |
| Sample application | [Example Flask app](https://github.com/launchdarkly/observability-sdk/blob/main/e2e/python-plugin-flask/README.md) |
| Published module | [PyPI](https://pypi.org/project/launchdarkly-observability) |

## Prerequisites and dependencies

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

The observability plugin is compatible with the [Python SDK](/sdk/server-side/python), version 9.12.0 and later. Using the observability plugin requires Python 3.10.0 or higher.

## Get started

Follow these steps to get started:

* [Install the plugin](#install-the-plugin)
* [Initialize the Python 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 Python 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="Shell" theme={null}
      pip install launchdarkly-server-sdk
      pip install launchdarkly-observability
  ```
</CodeGroup>

Then, import the plugin into your code:

<CodeGroup>
  ```python title="Python" theme={null}
      import ldclient
      from ldclient.config import Config

      import ldobserve
      from ldobserve import ObservabilityConfig, ObservabilityPlugin, observe
  ```
</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](/sdk/server-side/python#initialize-the-client) in the Python SDK reference guide.

Here's how to initialize the SDK and plugin:

<CodeGroup>
  ```python title="Initialize, Python SDK v9.12+" theme={null}
      plugin = ObservabilityPlugin()

      config = Config(
        sdk_key = "YOUR_SDK_KEY",
        plugins = [plugin]
      )
      ldclient.set_config(config)
      client = ldclient.get()
  ```
</CodeGroup>

## 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>
  ```python title="Plugin options, Python SDK v9.12+" theme={null}
      observability_config = ObservabilityConfig(
        service_name = "example-service",
        # we recommend setting service_version to the latest deployed git SHA
        service_version = "example-sha"
      )

      plugin = ObservabilityPlugin(observability_config)
  ```
</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](/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](/sdk/features/observability-config-server-side#python)
* [Errors](/sdk/features/observability-errors#python)
* [Logs](/sdk/features/observability-logs#python)
* [Metrics](/sdk/features/observability-metrics#python)
* [Tracing](/sdk/features/observability-traces#python)

## 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](/home/observability).

Specifically, the observability data includes events that LaunchDarkly uses to automatically create the following metrics:

* User HTTP error rate (OpenTelemetry)
* User HTTP 5XX response rate (OpenTelemetry)
* User non-HTTP exception rate (OpenTelemetry)
* Average, P95, and P99 request latency (OpenTelemetry)

To learn more, read [Metrics autogenerated from OpenTelemetry data](/home/metrics/autogen/opentelemetry).
