Skip to content

Conversation

@addisonbeck
Copy link
Contributor

@addisonbeck addisonbeck commented Dec 20, 2025

🎟️ Tracking

📔 Objective

This PR introduces an optional UNIFFI logging callback that enables mobile clients to receive SDK trace events and forward them to Flight Recorder observability systems.

The changes add a new LogCallback trait that allows mobile teams to register a callback during Client::new() initialization. When registered, the SDK forwards all INFO+ log events through this callback alongside existing platform loggers (oslog, android_logger). The callback is completely optional - existing SDK clients continue functioning without code changes.

Documentation

Please review crates/bitwarden-uniffi/docs/logging-callback.md for comprehensive details including:

  • Complete architecture and integration patterns
  • Thread safety requirements and implementation guidance
  • Known limitations and design decisions

The documentation is the authoritative reference for this feature. You can also find a tech breakdown linked in the Tracking section.

Side Effect: CI Disk Cleanup

This PR also adds a disk cleanup action for Ubuntu test runners (.github/actions/free-ubuntu-runner-disk-space/). The integration test suite compiles 5 separate test binaries alongside the full SDK workspace, requiring a lot of disk space. Without cleanup, Ubuntu runners exhaust available disk during compilation.

Demo

Also included is an example showing how to use the callback. It, alongside the tests, are the assertions that the whole thing works. Here is a screenshot showing the output of the example:

Screenshot 2025-12-23 at 4 34 19 PM

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@github-actions
Copy link
Contributor

github-actions bot commented Dec 20, 2025

Logo
Checkmarx One – Scan Summary & Details9c9341ed-f6c6-4745-a1f9-a2b26e932977

Great job! No new security vulnerabilities introduced in this pull request

@github-actions
Copy link
Contributor

github-actions bot commented Dec 20, 2025

🔍 SDK Breaking Change Detection Status

SDK Version: PM-27800-expose-sdk-tracing-flight-recorder (68a6590)
Started: 2025-12-23 22:19:14 UTC
Progress: 🚀 Triggering client workflows and waiting for completion...


Results will be updated when workflow completes. View SDK workflow

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 83.82353% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.07%. Comparing base (54d3f30) to head (26a4f0a).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/bitwarden-uniffi/src/log_callback.rs 86.84% 5 Missing ⚠️
crates/bitwarden-uniffi/src/error.rs 0.00% 3 Missing ⚠️
crates/bitwarden-uniffi/src/lib.rs 88.88% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #627      +/-   ##
==========================================
+ Coverage   78.87%   79.07%   +0.19%     
==========================================
  Files         283      285       +2     
  Lines       29680    29805     +125     
==========================================
+ Hits        23410    23568     +158     
+ Misses       6270     6237      -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@addisonbeck addisonbeck force-pushed the PM-27800-expose-sdk-tracing-flight-recorder branch 6 times, most recently from cee9fbf to b072562 Compare December 23, 2025 21:42
@addisonbeck addisonbeck force-pushed the PM-27800-expose-sdk-tracing-flight-recorder branch 2 times, most recently from 2efef50 to 26a4f0a Compare December 23, 2025 21:57
Adds an optional LogCallback trait that mobile clients can implement
to receive SDK log events for forwarding to Flight Recorder or other
observability systems. The callback integrates with the existing
tracing infrastructure from PM-26930 using a custom Layer that
forwards INFO+ events to registered callbacks.

The implementation includes CallbackLayer for event forwarding,
MessageVisitor for extracting log data, and error handling to ensure
callback failures don't crash the SDK. The callback parameter is
optional to maintain backward compatibility with existing clients.

Comprehensive test coverage includes unit tests and integration tests
in separate processes to validate thread safety, error handling, and
multi-level log forwarding without Once initialization conflicts.
Adds a reusable GitHub action that removes unused toolchains and
packages before running tests on ubuntu-24.04 runners. The cleanup
frees approximately 30GB by removing .NET SDKs, Android SDK, Swift
toolchain, Java JDKs, and other pre-installed software not needed
for Rust compilation.

This prevents "No space left on device" errors that occur when
compiling the integration test suite alongside the full SDK workspace.
The action runs only on Linux runners since macOS and Windows have
sufficient disk space.
@addisonbeck addisonbeck force-pushed the PM-27800-expose-sdk-tracing-flight-recorder branch from 26a4f0a to 68a6590 Compare December 23, 2025 22:12
@addisonbeck addisonbeck changed the title feat(client): support forwarding sdk logs to clients feat(uniffi): add logging callback for mobile observability Dec 23, 2025
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