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

# Go 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 Go SDK.

The Go 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://pkg.go.dev/github.com/launchdarkly/observability-sdk/go)</td>
      </tr>

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

      <tr>
        <td>Sample application</td>
        <td>[Example applications](#examples-using-different-frameworks) for several frameworks</td>
      </tr>

      <tr>
        <td>Published module</td>
        <td>[pkg.go.dev](https://pkg.go.dev/github.com/launchdarkly/observability-sdk/go)</td>
      </tr>
    </tbody>
  </table>
</Note>

## Prerequisites and dependencies

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

The observability plugin is compatible with the [Go SDK](/docs/sdk/server-side/go), version 7.11 and later. Using the observability plugin requires Go 1.24.3 or higher.

## Get started

Follow these steps to get started:

* [Install the plugin](#install-the-plugin)
* [Initialize the Go 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 Go SDK to provide observability.

The first step is to make both the SDK and the observability plugin available as dependencies. How you do this depends on what dependency management system you are using:

* If you are using the standard [Go modules](https://github.com/golang/go/wiki/Modules) system, import the SDK packages in your code and `go build` will automatically download them. The SDK and its dependencies are modules.
* Otherwise, use the `go get` command and specify the SDK version, such as `go get github.com/launchdarkly/go-server-sdk/v7` and `go get github.com/launchdarkly/observability-sdk/go`.

There are several packages that you can import, depending on which features you are using. To work with observability, you need the following:

<CodeGroup>
  ```go title="Go SDK v7.11+" lines wrap theme={null}
  import (
      // go-sdk-common/v3/ldcontext defines LaunchDarkly's model for contexts
      "github.com/launchdarkly/go-sdk-common/v3/ldcontext"

      // go-server-sdk/v7 is the main SDK package - here we are aliasing it to "ld"
      ld "github.com/launchdarkly/go-server-sdk/v7"

      // go-server-sdk/v7/ldplugins allows you to add plugins to the main SDK
      "github.com/launchdarkly/go-server-sdk/v7/ldplugins"

      // observability-sdk/go is the observability plugin - here we are aliasing it to "ldobserve"
      // this package requires go-server-sdk/v7 version 7.11 or later
      ldobserve "github.com/launchdarkly/observability-sdk/go"
  )
  ```
</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/go#initialize-the-client) in the Go SDK reference guide.

Here's how to initialize the SDK and plugin:

<CodeGroup>
  ```go title="Initialize, Go SDK v7.11+" lines wrap theme={null}
  client, _ := ld.MakeCustomClient("YOUR_SDK_KEY",
    ld.Config{
      Plugins: []ldplugins.Plugin{
        ldobserve.NewObservabilityPlugin()
      },
    }, 5*time.Second)
  ```
</CodeGroup>

## Configure the plugin options

You can configure options for the observability plugin when you initialize the SDK. The plugin constructor takes an optional function with the configuration details.

Here is an example:

<CodeGroup>
  ```go title="Plugin options, Go SDK v7.11+" lines wrap theme={null}
  client, _ := ld.MakeCustomClient("YOUR_SDK_KEY",
    ld.Config{
      Plugins: []ldplugins.Plugin{
        ldobserve.NewObservabilityPlugin(
          ldobserve.WithServiceName("example-service"),
          ldobserve.WithServiceVersion("example-sha"),
        ),
      },
    }, 5*time.Second)
  ```
</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).

## Examples using different frameworks

LaunchDarkly provides several examples, each demonstrating the LaunchDarkly Observability plugin with different Go frameworks and libraries:

* [Fiber example](https://github.com/launchdarkly/observability-sdk/blob/main/e2e/go-plugin/README.md#1-fiber-example-cmdfiber)
* [Gin example](https://github.com/launchdarkly/observability-sdk/blob/main/e2e/go-plugin/README.md#2-gin-example-cmdgin)
* [Gorilla Mux example](https://github.com/launchdarkly/observability-sdk/blob/main/e2e/go-plugin/README.md#3-gorilla-mux-example-cmdgorillamux)
* [Standard HTTP example](https://github.com/launchdarkly/observability-sdk/blob/main/e2e/go-plugin/README.md#4-standard-http-example-cmdhttp)
* [Logrus example](https://github.com/launchdarkly/observability-sdk/blob/main/e2e/go-plugin/README.md#5-logrus-example-cmdlogrus)

## 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#go)
* [Errors](/docs/sdk/features/observability-errors#go)
* [Logs](/docs/sdk/features/observability-logs#go)
* [Metrics](/docs/sdk/features/observability-metrics#go)
* [Tracing](/docs/sdk/features/observability-traces#go)

## 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).
