Skip to content

Commit 8f16a78

Browse files
committed
review feedback
1 parent f4bd9b8 commit 8f16a78

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

docs/adr/0008-use-tracing.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
Currently all Rust code in [app-services](https://github.com/mozilla/application-services/)
1616
uses the `log` crate for debugging and diagnostics.
17-
Log output is often captured during tests where it's just printed to stdout/stderr if the test
18-
fails. Further, both our mobile apps and Firefox Desktop have techniques for having this log
19-
output be sent across the FFI so it can be captured in whatever "native" logging system is
20-
in place (eg, logcat on Android, custom file logging on iOS, Log.sys.mjs/Console.sys.mjs logging on Desktop)
17+
Log output is valuable for working on the code, and for helping users troubleshoot.
18+
When working on the code, log output is often captured during tests, where it's just printed to stdout/stderr if the test fails.
19+
For helping users troubleshoot, log output is sent across the FFI so it can be captured in whatever "native" logging system is in place.
20+
Users or QA can then export and attach the logs to a bug.
2121

2222
application-services also has an [error support crate](https://github.com/mozilla/application-services/tree/main/components/support/error),
2323
designed explicitly for error reporting for the applications.
@@ -31,14 +31,16 @@ and any changes proposed to this crate by this document are limited to just this
3131

3232
The main problem with the `log` module is a design choice made by that crate,
3333
which is the concept of a [global "max level"](https://docs.rs/cli-log/latest/cli_log/fn.set_max_level.html)
34+
that's set for all crates.
3435

35-
In Gecko, simply setting this max level to, say, `Trace` can cause performance regressions in other
36-
crates - eg, [see this desktop bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1874215) for one example.
36+
The Gecko code has embraced this design choice and sets the global max level to Info for production builds.
37+
Changing this max level to, say, Trace can cause performance regressions in other crates - eg, see this desktop bug for one example.
38+
Changing all the existing code is a difficult, and probably unwelcome, task, and is only possible for crates we control.
3739

3840
In practice, this means that we are unable to selectively get `Debug` or `Trace` logs for individual components,
3941
because the max level for the logger is, effectively, fixed at `Info`.
4042

41-
### Problems with the error reporter
43+
#### Problems with the error reporter
4244

4345
The error reporter actually works OK for mobile, but is not implemented at all for Desktop.
4446
However, the existing implementation is quite ad-hoc and not very "rich" in terms of data which
@@ -81,6 +83,11 @@ This document proposes that:
8183

8284
* This same mechanism, and the same raw data, should be used on all platforms (ie, Android, iOS and Desktop).
8385

86+
To be explicit, there would be no requirement for any other crates to move to tracing. However, we also
87+
believe there is nothing in this document which would prevent any crates from using tracing.
88+
Further, there's no reason that the use of `log` and `tracing` is mutually exclusive; crates are, and will remain, free
89+
to use either of these crates as they see fit.
90+
8491
## Implementation: Move to tracing for all app-services crates.
8592

8693
This section describes the changes necessary to implement the above.
@@ -122,6 +129,7 @@ simply subscribe to the highest log level and perform additional filtering after
122129
This means that the "performance critical path" for this process is determining if we have a subscriber;
123130
once we have determined a subscriber matches an event, we can perform relatively expensive operations
124131
on the event because we assume action will be taken on the event.
132+
We believe this assumption is fine because we will own all such subscribers.
125133

126134
An example of these "relatively expensive" operations is fetching event "fields", such as the message or other meta-data.
127135

@@ -134,7 +142,9 @@ There are 3 main places which would change in the first instance, broken down by
134142

135143
#### Mobile
136144

137-
The existing [rust_log_forwarder](https://github.com/mozilla/application-services/tree/main/components/support/rust-log-forwarder) and [error-support](https://github.com/mozilla/application-services/tree/main/components/support/error) crates would change how they collect "events" to using `tracing-subscriber`. Initially we'd not change the API exposed to the mobile apps, but very soon after declaring success on Desktop we'd look to consolidate the APIs as seen by the applications.
145+
As described in the Application Services section, the existing crates used by mobile would keep the same public API
146+
in the first instance, meaning our mobile apps would not require changes; however, eventually we'd look at moving
147+
the mobile apps to the new mechanism, at which time we'd kill the 2 "legacy" app-services crates.
138148

139149
#### Desktop
140150

@@ -149,7 +159,7 @@ The [app-services-logger](https://searchfox.org/mozilla-central/source/services/
149159

150160
#### Application Services
151161

152-
* All crates move to `tracing` instead of `logging`
162+
* All crates move to `tracing` instead of `log`
153163

154164
* A new crate would be added which defines the application callback interfaces (via UniFFI) and
155165
also the new tracing-subscriber implementation.
@@ -158,8 +168,3 @@ The [app-services-logger](https://searchfox.org/mozilla-central/source/services/
158168
but would have their internal implementation replaced with the subscriber. This is for backwards
159169
compatibility with mobile - eventually we'd expose the new callback interfaces to mobile and delete
160170
these crates entirely.
161-
162-
#### Mobile
163-
164-
Mobile would not require changes in the first version, although we'd move to the new mechanism within
165-
a month or 2, at which time we can kill the 2 "legacy" app-services crates.

0 commit comments

Comments
 (0)