![]() |
VOOZH | about |
dotnet add package LaunchDarkly.DemoObservability --version 0.57.0
NuGet\Install-Package LaunchDarkly.DemoObservability -Version 0.57.0
<PackageReference Include="LaunchDarkly.DemoObservability" Version="0.57.0" />
<PackageVersion Include="LaunchDarkly.DemoObservability" Version="0.57.0" />Directory.Packages.props
<PackageReference Include="LaunchDarkly.DemoObservability" />Project file
paket add LaunchDarkly.DemoObservability --version 0.57.0
#r "nuget: LaunchDarkly.DemoObservability, 0.57.0"
#:package LaunchDarkly.DemoObservability@0.57.0
#addin nuget:?package=LaunchDarkly.DemoObservability&version=0.57.0Install as a Cake Addin
#tool nuget:?package=LaunchDarkly.DemoObservability&version=0.57.0Install as a Cake Tool
The LaunchDarkly Observability SDK for .NET MAUI provides automatic and manual instrumentation for your mobile application, including metrics, logs, error reporting, and session replay.
NB: APIs are subject to change until a 1.x version is released.
The .NET MAUI observability plugin automatically instruments:
A complete example application is available in the directory.
In your MauiProgram.cs (or wherever you initialize your application), register the ObservabilityPlugin via LdClient:
using LaunchDarkly.Observability;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
using LaunchDarkly.Sdk.Client.Integrations;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// ... other configuration ...
var mobileKey = "your-mobile-key";
var ldConfig = Configuration.Builder(mobileKey, ConfigurationBuilder.AutoEnvAttributes.Enabled)
.Plugins(new PluginConfigurationBuilder()
.Add(new ObservabilityPlugin(new ObservabilityOptions(
isEnabled: true,
serviceName: "maui-sample-app"
)))
).Build();
var context = Context.New("maui-user-key");
var client = LdClient.Init(ldConfig, context, TimeSpan.FromSeconds(10));
return builder.Build();
}
}
After initialization of the LaunchDarkly client, use LDObserve to record metrics, logs, and errors:
using LaunchDarkly.Observability;
// Record metrics
LDObserve.RecordMetric("user_actions", 1.0);
LDObserve.RecordCount("api_calls", 1.0);
LDObserve.RecordIncr("page_views", 1.0);
LDObserve.RecordHistogram("response_time", 150.0);
LDObserve.RecordUpDownCounter("active_connections", 1.0);
// Record logs with severity and optional attributes
LDObserve.RecordLog(
"User performed action",
LDObserve.Severity.Info,
new Dictionary<string, object?>
{
{ "user_id", "12345" },
{ "action", "button_click" }
}
);
// Record errors with an optional cause
LDObserve.RecordError("Something went wrong", "The underlying cause of the error.");
| Method | Description |
|---|---|
RecordMetric(name, value) |
Record a gauge metric |
RecordCount(name, value) |
Record a count metric |
RecordIncr(name, value) |
Record an incremental counter metric |
RecordHistogram(name, value) |
Record a histogram metric |
RecordUpDownCounter(name, value) |
Record an up-down counter metric |
Use RecordLog to emit structured log records with a severity level and optional attributes:
LDObserve.RecordLog(
"Checkout completed",
LDObserve.Severity.Info,
new Dictionary<string, object?>
{
{ "order_id", "ORD-9876" },
{ "total", 42.99 }
}
);
Supported severity levels: Trace, Debug, Info, Warn, Error, Fatal.
Use RecordError to capture error events. The optional second parameter provides the underlying cause:
LDObserve.RecordError("Payment failed", "Timeout connecting to payment gateway.");
Use LDObserve to create spans for tracing operations in your application. Spans are backed by OpenTelemetry and should be disposed when the operation completes.
Create spans to trace operations. The returned TelemetrySpan is disposable — wrap it in a using statement so it ends automatically:
using var span = LDObserve.StartActiveSpan("api_request");
span.SetAttribute("endpoint", "/api/users");
span.SetAttribute("method", "GET");
StartActiveSpan automatically creates parent-child relationships. Each new active span becomes a child of the currently active span:
using var parent = LDObserve.StartActiveSpan("ProcessOrder");
using var child = LDObserve.StartActiveSpan("ValidatePayment");
using var grandchild = LDObserve.StartActiveSpan("ChargeCard");
await httpClient.PostAsync("https://api.example.com/charge", content);
| Method | Description |
|---|---|
LDObserve.StartActiveSpan(name) |
Start a new active span that automatically nests under the current parent. Returns a disposable TelemetrySpan. |
span.SetAttribute(key, value) |
Set a key-value attribute on a span. |
Use the LaunchDarkly client to identify or switch user contexts. This ties observability data to the correct user:
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
// Single context
var userContext = Context.Builder("user-key")
.Name("Bob Bobberson")
.Build();
await LdClient.Instance.IdentifyAsync(userContext);
// Multi-context
var userContext = Context.Builder("user-key")
.Name("Bob Bobberson")
.Build();
var deviceContext = Context.Builder(ContextKind.Of("device"), "iphone")
.Name("iphone")
.Build();
var multiContext = Context.MultiBuilder()
.Add(userContext)
.Add(deviceContext)
.Build();
LdClient.Instance.Identify(multiContext, TimeSpan.FromSeconds(5));
// Anonymous context
var anonContext = Context.Builder("anonymous-key")
.Anonymous(true)
.Build();
LdClient.Instance.Identify(anonContext, TimeSpan.FromSeconds(5));
Session Replay captures user interactions and screen recordings to help you understand how users interact with your application. To enable Session Replay, add the SessionReplayPlugin alongside the ObservabilityPlugin:
using LaunchDarkly.SessionReplay;
using LaunchDarkly.Observability;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Client;
using LaunchDarkly.Sdk.Client.Integrations;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// ... other configuration ...
var mobileKey = "your-mobile-key";
var ldConfig = Configuration.Builder(mobileKey, ConfigurationBuilder.AutoEnvAttributes.Enabled)
.Plugins(new PluginConfigurationBuilder()
.Add(new ObservabilityPlugin(new ObservabilityOptions(
isEnabled: true,
serviceName: "maui-sample-app"
)))
.Add(new SessionReplayPlugin(new SessionReplayOptions(
isEnabled: true,
privacy: new SessionReplayOptions.PrivacyOptions(
maskTextInputs: true,
maskWebViews: false,
maskLabels: false
)
)))
).Build();
var context = Context.New("maui-user-key");
var client = LdClient.Init(ldConfig, context, TimeSpan.FromSeconds(10));
return builder.Build();
}
}
You can control what information is captured during a session using PrivacyOptions:
MaskTextInputs: (Default: true) Masks all text input fields.MaskWebViews: (Default: false) Masks all web view content.MaskLabels: (Default: false) Masks all text labels.MaskImages: (Default: false) Masks all images.You can manually mask or unmask specific UI components using the provided extension methods on any MAUI View.
using LaunchDarkly.SessionReplay;
// Mask a specific view
mySensitiveView.LDMask();
// Unmask a specific view
myPublicView.LDUnmask();
We encourage pull requests and other contributions from the community. Check out our for instructions on how to contribute to this SDK.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0-android35.0 net9.0-android35.0 is compatible. net9.0-ios18.0 net9.0-ios18.0 is compatible. net10.0-android net10.0-android was computed. net10.0-ios net10.0-ios was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.57.0 | 130 | 3/24/2026 | |
| 0.56.0 | 117 | 3/24/2026 | |
| 0.55.0 | 114 | 3/18/2026 | |
| 0.54.0 | 114 | 3/18/2026 | |
| 0.53.0 | 111 | 3/18/2026 | |
| 0.52.0 | 117 | 3/12/2026 | |
| 0.50.0 | 122 | 3/12/2026 | |
| 0.49.0 | 118 | 3/12/2026 | |
| 0.47.0 | 129 | 3/12/2026 | |
| 0.46.0 | 123 | 3/12/2026 | |
| 0.43.0 | 109 | 3/3/2026 | |
| 0.42.0 | 151 | 1/28/2026 | 0.42.0 is deprecated because it is no longer maintained. |
| 0.4.0 | 117 | 3/11/2026 |