Skip to content

feat: MAUI Network tracing 0.8.0#463

Merged
abelonogov-ld merged 23 commits intomainfrom
andrey/maui-network
Apr 9, 2026
Merged

feat: MAUI Network tracing 0.8.0#463
abelonogov-ld merged 23 commits intomainfrom
andrey/maui-network

Conversation

@abelonogov-ld
Copy link
Copy Markdown
Contributor

@abelonogov-ld abelonogov-ld commented Apr 9, 2026

Summary

  • Network request tracing for .NET MAUI: Adds System.Net.Http Activity source to LDTracer so HTTP requests made from .NET are automatically captured as spans. On iOS, native urlSession instrumentation is disabled since tracing now happens on the .NET side. On Android, UseNativeHttpHandler is set to false in the sample project so SocketsHttpHandler emits Activity diagnostics.
  • Configurable instrumentation options: Introduces InstrumentationOptions (with NetworkRequests and LaunchTimes toggles) on ObservabilityOptions, plumbed through the iOS (Swift) and Android (Kotlin) native bridges so each instrumentation can be individually enabled/disabled from the .NET layer.
  • Span-context-aware logging: LDObserve.RecordLog now accepts an optional SpanContext? parameter. When provided, its trace/span IDs are forwarded to the native logger; otherwise the ambient Activity.Current is used. The native logger is obtained via new ObjcLogger (iOS) and RealLogger (Android) bridge classes, replacing the old recordLog method on ObservabilityBridge.
  • New public APIs on LDObserve: RecordError(Exception), StartRootSpan(string), and GetTracer() (with no-op fallback before init).
  • Android SDK: TracesApi.startSpan now defaults attributes to Attributes.empty().
  • E2E example: Android ViewModel demonstrates parent/child span creation and cross-thread context propagation.
  • Version bump: LaunchDarkly.SessionReplay 0.6.0 → 0.8.0.
image

Changes by area

.NET SDK (mobile-dotnet/observability)

  • New InstrumentationOptions class with NetworkRequests and LaunchTimes booleans (default true), added to ObservabilityOptions.
  • ObservabilityPlugin enables System.Net.Http.EnableActivityPropagation when network request tracing is on.
  • LDTracer is no longer a singleton; accepts serviceName and networkRequests params; conditionally subscribes to System.Net.Http Activity source.
  • New ObservabilityService consolidates all bridge calls, tracer lifecycle, and native logger acquisition. Replaces deleted NativeObserve.
  • LDObserve is now a thin static facade over ObservabilityService; safe to call before initialization (no-ops).
  • PluginOrchestrator renamed properties to ObservabilityService / SessionReplayService; calls LDObserve.Initialize() after native start.
  • Native bridge mappings (LDNative.Android.cs, SRClient.iOS.cs) pass new instrumentation options through.

Native bridges — iOS (Swift)

  • ObjcObservabilityOptions adds networkRequests and launchTimes properties.
  • ObservabilityBridge disables urlSession instrumentation and makes launchTimes configurable.
  • New ObjcLogger class exposed via LDObserveBridge.getObjcLogger().
  • iOS binding ApiDefinition.cs updated with new properties and ObjcLogger interface.

Native bridges — Android (Kotlin)

  • LDObservabilityOptions adds launchTime field; options classes moved to OptionsBridge.kt.
  • ObservabilityBridge reads launchTime from options instead of hardcoding true; recordLog removed.
  • New RealLogger wrapper around KotlinLogger for C# binding.
  • LDObserveBridgeAdapter exposes getLogger().

Android SDK (observability-android)

  • TracesApi.startSpan parameter attributes now defaults to Attributes.empty().

E2E / Sample

  • Android e2e ViewModel demonstrates parent-child span creation and cross-thread context propagation.
  • MAUI sample MauiProgram.cs uses the new InstrumentationOptions API.
  • MAUI sample .csproj sets UseNativeHttpHandler=false for Android to enable System.Net.Http Activity diagnostics.

Note

Medium Risk
Touches cross-platform observability initialization and tracing sources (including automatic System.Net.Http span capture), so misconfiguration could change telemetry volume/correlation or miss spans on iOS/Android.

Overview
Adds automatic .NET MAUI HTTP request tracing by extending LDTracer to optionally subscribe to the System.Net.Http Activity source and enabling System.Net.Http.EnableActivityPropagation when configured.

Introduces InstrumentationOptions on ObservabilityOptions (toggles for NetworkRequests and LaunchTimes) and plumbs these through the Android (Kotlin) and iOS (Swift + binding) native bridges; iOS disables native urlSession tracing in favor of .NET-side tracing, and Android bridge now respects a configurable launchTime flag.

Hardens initialization by making PluginOrchestrator initialize only once, updates samples/e2e to demonstrate cross-thread span context propagation and config usage (including Android UseNativeHttpHandler=false), and bumps LaunchDarkly.SessionReplay package version to 0.8.0.

Reviewed by Cursor Bugbot for commit abda519. Bugbot is set up for automated code reviews on this repo. Configure here.

- Introduced `triggerLogWithContext` method in ViewModel to log messages with OpenTelemetry span context.
- Added a button in MainActivity to trigger the new logging functionality, enhancing observability in detached threads.
- Cleaned up imports in `LDObserve.kt`, `ObservabilityHookExporter.kt`, `ViewModel.kt`, `ObservabilityServiceTasks.kt`, `SamplingE2ETest.kt`, and `DisablingConfigOptionsE2ETest.kt` by removing the unused `recordLog` import.
- Updated `recordLog` method signature in `Observe.kt` to provide default values for attributes and spanContext, simplifying its usage.
- Introduced a new button in MainPage.xaml to trigger logging with OpenTelemetry span context.
- Implemented OnTriggerLogWithContextClicked method in MainPage.xaml.cs to log messages with associated span context.
- Updated LDObserve to support optional span context in the RecordLog method, enhancing trace-log correlation capabilities.
…ization logic

- Renamed the TryInitializeAll method to InitializeAll for clarity.
- Updated the initialization logic to only call LDObserve.Initialize if observability options are enabled.
- Adjusted the Register method to call the renamed InitializeAll method.
@abelonogov-ld abelonogov-ld requested a review from a team as a code owner April 9, 2026 01:03
@abelonogov-ld abelonogov-ld changed the title Andrey/maui network feat: MAUI Network tracing Apr 9, 2026
@abelonogov-ld abelonogov-ld changed the title feat: MAUI Network tracing feat: MAUI Network tracing 0.8.0 Apr 9, 2026
- Introduced `triggerLogWithContext` method in ViewModel to log messages with OpenTelemetry span context.
- Added a button in MainActivity to trigger the new logging functionality, enhancing observability in detached threads.
- Cleaned up imports in `LDObserve.kt`, `ObservabilityHookExporter.kt`, `ViewModel.kt`, `ObservabilityServiceTasks.kt`, `SamplingE2ETest.kt`, and `DisablingConfigOptionsE2ETest.kt` by removing the unused `recordLog` import.
- Updated `recordLog` method signature in `Observe.kt` to provide default values for attributes and spanContext, simplifying its usage.
Comment thread sdk/@launchdarkly/mobile-dotnet/observability/infra/PluginOrchestrator.cs Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 86839b9. Configure here.

@abelonogov-ld abelonogov-ld enabled auto-merge (squash) April 9, 2026 16:18
@abelonogov-ld abelonogov-ld merged commit 0e2482b into main Apr 9, 2026
25 checks passed
@abelonogov-ld abelonogov-ld deleted the andrey/maui-network branch April 9, 2026 16:30
abelonogov-ld pushed a commit that referenced this pull request Apr 10, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>launchdarkly-observability-android: 0.37.0</summary>

##
[0.37.0](launchdarkly-observability-android-0.36.0...launchdarkly-observability-android-0.37.0)
(2026-04-09)


### Features

* MAUI Network tracing 0.8.0
([#463](#463))
([0e2482b](0e2482b))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: this PR only updates release/version metadata and the
changelog, with no functional code changes.
> 
> **Overview**
> Bumps `sdk/@launchdarkly/observability-android` from `0.36.0` to
`0.37.0` in the release manifest and Gradle properties.
> 
> Updates `sdk/@launchdarkly/observability-android/CHANGELOG.md` with
the `0.37.0` release entry (MAUI network tracing `0.8.0`).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
11a360d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants