ldotel

package module
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 1

README

LaunchDarkly Server-side OTEL library for Go

Actions Status

LaunchDarkly overview

LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!

Twitter Follow

Getting started

Import the module:

import (
    "github.com/launchdarkly/go-server-sdk/ldotel"
)

Configure the LaunchDarkly client to use a tracing hook:

client, _ = ld.MakeCustomClient("your-sdk-key",
ld.Config{
    Hooks: []ldhooks.Hook{ldotel.NewTracingHook()},
}, 5*time.Second)

Learn more

Read our documentation for in-depth instructions on configuring and using LaunchDarkly.

Contributing

We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this library.

About LaunchDarkly

  • LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
    • Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
    • Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
    • Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
    • Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
  • LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read our documentation for a complete list.
  • Explore LaunchDarkly

Documentation

Overview

Package ldotel contains OpenTelemetry specific implementations of hooks.

For instance, to use LaunchDarkly with OpenTelemetry tracing, one would use the TracingHook:

client, _ = ld.MakeCustomClient("sdk-key", ld.Config{
	    Hooks: []ldhooks.Hook{ldotel.NewTracingHook()},
	}, 5*time.Second)

Index

Constants

View Source
const Version = "1.3.1" // {{ x-release-please-version }}

Version is the current version string of the ldotel package. This is updated by our release scripts.

Variables

This section is empty.

Functions

This section is empty.

Types

type TracingHook

type TracingHook struct {
	ldhooks.Unimplemented
	// contains filtered or unexported fields
}

A TracingHook adds OpenTelemetry support to the LaunchDarkly SDK.

By default, span events will be added for each call to a "Variation" method. Variation methods without "Ctx" will not be able to access a parent span, so no span events can be attached. If WithSpans is used, then root spans will be created from the non-"Ctx" methods.

The span event will include the FullyQualifiedKey of the ldcontext, the provider of the evaluation (LaunchDarkly), and the key of the flag being evaluated.

func NewTracingHook

func NewTracingHook(opts ...TracingHookOption) TracingHook

NewTracingHook creates a new TracingHook instance. The TracingHook can be provided to the LaunchDarkly client in order to add OpenTelemetry support.

func (TracingHook) AfterEvaluation

AfterEvaluation implements the AfterEvaluation evaluation stage.

func (TracingHook) BeforeEvaluation

BeforeEvaluation implements the BeforeEvaluation evaluation stage.

func (TracingHook) Metadata

func (h TracingHook) Metadata() ldhooks.Metadata

Metadata returns meta-data about the tracing hook.

type TracingHookOption

type TracingHookOption func(hook *TracingHook)

TracingHookOption is used to implement functional options for the TracingHook.

func WithEnvironmentID added in v1.3.0

func WithEnvironmentID(environmentID string) TracingHookOption

WithEnvironmentID option sets the environemntID to be used as feature_flag.set.id, which will override any environmentID supplied by the hook series context.

func WithSpans

func WithSpans() TracingHookOption

WithSpans is an experimental option that enables creation of child spans for each variation call.

This feature is experimental and the data in the spans, or nesting of spans, could change in future versions.

func WithValue added in v1.2.0

func WithValue() TracingHookOption

WithValue option enables putting a stringified version of the flag value in the feature_flag span event.

func WithVariant deprecated

func WithVariant() TracingHookOption

WithVariant option enables putting a stringified version of the flag value in the feature_flag span event.

Deprecated: Use WithValue instead.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL