This topic explains how to record traces through the SDK observability plugin.
You can view all traces sent to LaunchDarkly under Traces in the LaunchDarkly user interface. To learn more, read Traces.
Details about each SDK’s configuration are available in the SDK-specific sections below:
This feature is available in the observability plugin for the following client-side SDKs:
To build and start a new span:
The attributes argument should include the details to record with the span. To construct it, use Attributes from the @opentelemetry/api.
To start a new span:
The attributes argument should include the details to record with the span. To construct it, use Attributes from the @opentelemetry/api.
The observability plugin provides two options for starting new spans:
startSpan() ends the span automatically after the callback function completes, whether it returns normally or throws an errorstartManualSpan() ends the span when you call span.end()To start a new span:
To learn more, read startSpan and startManualSpan.
The observability plugin provides a few options for starting new spans:
startSpan() starts a new span without making it activestartActiveSpan() starts a new span, makes it active, and runs a callback function within its contextstartWithHeaders() starts a new span with header contextHere’s an example:
To learn more, read Observe.
To start new spans with the React Web SDK, follow the example for JavaScript.
To start new spans with the React Web SDK, follow the example for JavaScript.
This feature is available in the observability plugin for the following server-side SDKs:
To start new spans within the observability plugin for .NET (server-side) SDK, use StartActivity. By default, it records any exceptions as error events on the span, and sets the span’s status appropriately.
Here’s how:
This method requires the Name of the span. Optionally, you can pass in attributes and specify whether to record an exception or set the span’s status if there is an exception. To construct the attributes argument, use Attributes from the @opentelemetry/api.
To learn more, read StartActivity.
To start new spans with in the observability plugin for the Go SDK, use StartSpan(). By default, this records any exceptions as error events on the span and sets the span’s status appropriately.
Here’s how:
The StartSpan method requires a Go context.Context, the name of the span, and an array of the OpenTelemetry options for starting a span. You can optionally pass an array of attributes from the OpenTelemetry specification.
To learn more, read StartSpan.
The Node.js (server-side) SDK’s observability plugin uses the OpenTelemetry Tracing API to work with spans.
Additionally, it provides the following functions for working with spans:
setAttributes() sets attributes on the active spanstartWithHeaders() starts a span with information from the request headersrunWithHeaders() runs a callback with information from the request headers and returns the resultHere’s an example:
To learn more, read Observe.
To start new spans with in the observability plugin for Python SDK, use start_span. This method is a context manager for creating a new span. By default, it records any exceptions as error events on the span, sets the span’s status appropriately. Exiting the context manager calls the span’s end method.
Here’s how:
This method requires the name of the span. Optionally, you can pass in attributes and specify whether to record an exception or set the span’s status if there is an exception. To construct the attributes argument, use Attributes from the @opentelemetry/api.
To learn more, read start_span.