Repository navigation
feat(maui): add SetAttributes and RemoveAttributes - #863
Open
abelonogov-ld wants to merge 5 commits into
Open
abelonogov-ld wants to merge 5 commits into
abelonogov-ld wants to merge 5 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Vadman97
approved these changes
Oct 29, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds global attributes to the .NET MAUI SDK, matching the other SDKs in this series (#858, #859, #860, #861, #856, launchdarkly/swift-launchdarkly-observability#290):
LDObserve.SetAttributes(IDictionary<string, object?>)/LDObserve.RemoveAttributes(IEnumerable<string>)merge into the native SDK's process-wide, in-memory map.session.idandhighlight.session_idare ignored on both platforms.LDObservemethods): calls are buffered in a thread-safe C# store and replayed into native right before the nativeStart, so telemetry recorded during native startup carries them too. After that, calls go straight to native under the same lock, so a racing write can't be overtaken by older buffered values.TelemetrySpan,System.Net.Http,RecordError) are exported through the native tracer viaLDTraceExporter/TraceBuilderAdapter, so native globals apply to them; Activity tags are copied after the native span starts, so they win over globals. Because the native span is created at export, a .NET span gets the globals current when its Activity ends.ObservabilityBridge.setAttributes/removeAttributes, Swift@objcstaticsetAttributes:/removeAttributes:, plus the iOS bindingApiDefinition.Custom span/log processors are intentionally not added for MAUI: telemetry is produced natively, and .NET processors would need a native→.NET callback for every span and log.
How did you test this change?
tests/LDObservability.Tests(12 tests) for the pending store: merge/remove/replay ordering, reserved keys, null values, snapshotting, and concurrent writes during bind.dotnet testpasses../gradlew :LDObserve:assembleRelease), the iOS xcframework (scripts/build_xcframework.sh, Xcode 27.1, against the chore: release main #290 checkout), both bindings,LDObservabilityfornet9.0-androidandnet9.0-ios, andMauiSample9for Android and the iOS simulator (the iOS sample needs-p:ValidateXcodeVersion=falselocally because .NET for iOS 26.2 expects Xcode 26.2).Are there any deployment considerations?
Package.resolvedwill need OpenTelemetry-Swift ≥ 2.5.0 when the iOS dependency is bumped (left out of this PR).Note
Overview
Adds process-wide global attributes to the .NET MAUI observability API via
LDObserve.SetAttributesandLDObserve.RemoveAttributes, aligned with the other mobile SDKs. Merged keys attach to subsequent spans, logs, and metrics (including native auto-instrumentation); per-call attributes still override globals. Reserved keyssession.idandhighlight.session_idare stripped, andnullvalues are ignored.Unlike other
LDObservecalls, pre-init usage is supported: a newGlobalAttributesBufferholds set/remove operations under a lock and replays them into native immediately beforeStartviaNativeGlobalAttributesSinkand new Android Kotlin / iOS Swift bridge methods (plus iOS binding exports). After bind, writes go straight to the native store.Documentation and the sample app exercise UTM-style globals set before init and per-call override on logs/spans. A new
LDObservability.TestsxUnit project linksGlobalAttributesBufferfor merge, remove, reserved keys, and concurrent-bind coverage.Reviewed by Cursor Bugbot for commit a3c9fda. Bugbot is set up for automated code reviews on this repo. Configure here.