Configuration for client-side observability
Overview
This topic explains how to configure the observability plugin for client-side SDKs.
The observability plugin collects and sends observability data to LaunchDarkly, so you can review error monitoring, logs, traces, and more from within the LaunchDarkly UI.
To get started with the observability plugin, read the observability reference guide for your SDK. Use the docs site navigation on the left, or find your SDK under Observability SDKs.
Details about each SDK’s configuration are available in the SDK-specific sections below:
Client-side SDKs
This feature is available in the observability plugin for the following client-side SDKs:
iOS
Expand iOS code sample
To specify the observability plugin configuration options, use Options for the plugin.
Here’s how:
For a complete list of configuration options, read Configuration.
Android
Expand Android code sample
To specify the observability plugin configuration options, use Options for the plugin.
Here’s how:
For a complete list of configuration options, read Options javadoc.
JavaScript
Expand JavaScript code sample
The observability plugin supports the following configuration options. After you initialize the SDK, you can set these when you configure the observability plugin options. Then, you can access the related features from within your application.
Recording network requests and WebSocket events
By default, the observability plugin shows you all the network request durations, response codes, and sizes for a session.
You can configure the options for the observability plugin to additionally record the headers and bodies of network requests and responses. Then, provide these options when you initialize the SDK client.
Here’s how to construct the options object:
By default, the plugin does not record the following headers:
AuthorizationCookieProxy-Authorization
To redact other headers, set networkRecording.networkHeadersToRedact. To redact specific keys in the request/response body, set networkRecording.networkBodyKeysToRedact. Alternatively, you can use an allowlist, and set networkRecording.headerKeysToRecord and networkRecording.bodyKeysToRecord.
By default, the plugins do not record the following URLs:
https://www.googleapis.com/identitytoolkithttps://securetoken.googleapis.com
To redact other URLs, for example if you have APIs that you know will always return secrets in their headers, body, or both, add the option urlBlocklist to your plugin options and set it to a list of URLs:
If none of these options are specific enough, you can write your own method to sanitize network responses. Define a networkRecording.requestResponseSanitizer function that receives a request/response pair and returns either null, if you want to drop the request entirely, or a sanitized request/response pair. We do not recommend dropping requests completely unless absolutely necessary, as it can cause issues with debugging due to the missing requests. Instead, we recommend deleting or redacting header and body fields in your requestResponseSanitizer function.
When networkRecording.recordHeadersAndBody is true, the plugins record all of the WebSocket events in your sessions, including opening a connection, sending and receiving messages, receiving an error, and closing a connection.
To disable WebSocket events, but keep recording the headers and bodies of network requests, set networkRecording.disableWebSocketEventRecordings to true.
Console messages
By default, the plugins show the console messages that were logged during a session.
To disable console recording, set disableConsoleRecording to true when you configure the plugin options for either the observability plugin or the session replay plugin.
If you are not seeing console logs in your session recordings, ensure that disableConsoleRecording is set to false in your plugin options.
To specify which console methods to record, set consoleMethodsToRecord.
Using a proxy
If your sessions or errors are not appearing in LaunchDarkly, it may be that requests to LaunchDarkly are being blocked. This may be happening for any of several reasons, including third-party browser extensions, browser configuration, or VPN settings.
If you have access to your domain’s DNS settings, you can set up a proxy from your domain to LaunchDarkly to avoid having requests blocked.
Here’s how:
-
On your domain, add two
CNAMErecords:- A
CNAMErecord that pointspub.ld.<your_domain>topub.observability.app.launchdarkly.com - A
CNAMErecord that pointsotel.ld.<your_domain>tootel.observability.app.launchdarkly.com
Together, these records mean that if you have an app running at
<your_domain>, your DNS records will pointpub.ld.<your_domain>andotel.ld.<your_domain>to the LaunchDarkly servers. - A
-
In your application, set the
backendUrlandoteloptions when you configure the observability plugin.- Set the
backendUrloption topub.ld.<your_domain> - Set the
oteloption tootel.ld.<your_domain>
Here’s how:
Plugin options - Set the
Fullstack mapping
We recommend instrumenting your application so that you can attribute frontend requests with backend errors and logs.
To do this, set following plugin options:
tracingOrigins:- set to the URI of your application’s backend API to propagate the trace context. Matching API requests include a
traceparentHTTP header that propagates the trace context, allowing server-side tracing and logging to associate its data with the frontend trace. - set to
trueto include all domains and subdomains of the URL for your frontend application. - set to an array of patterns matching the location of your backend if you want to include specific URLs. You’ll need to use this option if your application makes cross-origin requests that you would like to trace. For example, if your frontend sends requests to
https://backend.example.com/api, set the value to['backend.example.com/api'].
- set to the URI of your application’s backend API to propagate the trace context. Matching API requests include a
networkRecording:- set
enabledtotrue - set
recordHeadersAndBodytotrue
- set
Here’s how:
Versioning sessions and errors
When you configure the plugin options, you can optionally set a version field. The version is then included in the error and session views in the LaunchDarkly UI.
This version field is configured manually, and is separate from any versions that may be set if you configure automatic environment attributes in the LaunchDarkly SDK.
React Native
Expand React Native code sample
To specify the observability plugin configuration options, use the ReactNativeOptions interface to set the options.
Here’s how:
For a complete list of configuration options, read ReactNativeOptions.
React Web
Configuring the observability plugin in the React Web SDK follows the examples given for the JavaScript SDK.
Vue
Configuring the observability plugin in the Vue SDK follows the examples given for the JavaScript SDK.
Monkey patches
When the observability plugin runs, it monkey patches browser APIs in order to record errors, console messages, network requests, and changes on the page.
Expand Browser APIs subject to monkey patching
Browser APIs subject to monkey patching
Here is a list of the browser APIs that the LaunchDarkly observability plugins may monkey patch:
window.sessionStorage.setItemwindow.sessionStorage.getItemwindow.sessionStorage.removeItemwindow.onerrorwindow.fetchwindow.FontFacewindow.scrollwindow.scrollTowindow.scrollBywindow.scrollIntoViewwindow.WebGLRenderingContextwindow.WebGL2RenderingContextwindow.CanvasRenderingContext2Dwindow.HTMLCanvasElementwindow.CSSStyleSheet.prototype.insertRulewindow.CSSStyleSheet.prototype.deleteRulewindow.CSSGroupingRulewindow.CSSMediaRulewindow.CSSConditionRulewindow.CSSSupportsRulewindow.CSSStyleDeclaration.prototype.setPropertywindow.CSSStyleDeclaration.prototype.removePropertyhistory.pushStatehistory.replaceStateXMLHttpRequest.prototype.openXMLHttpRequest.prototype.setRequestHeaderXMLHttpRequest.prototype.sendconsole.assertconsole.clearconsole.countconsole.countResetconsole.debugconsole.dirconsole.dirxmlconsole.errorconsole.groupconsole.groupCollapsedconsole.groupEndconsole.infoconsole.logconsole.tableconsole.timeconsole.timeEndconsole.timeLogconsole.traceconsole.warn