Open
Description
Feature Request
Crates
tracing-core
Motivation
A common complaint with tracing
's filtering behavior is that feedback for invalid filters can be silent—there is no diagnostic saying "this target does not exist" because tracing-core
cannot tell the difference between a nonexistent callsite and a yet-to-be-discovered callsite, as callsite registration occurs as the instrumented code executes for the first time, not ahead of time.
To address this issue, this issue proposes that all callsites became statically visible and discoverable at program startup. This would allow other, higher-level libraries to find all callsites and implement interesting functionality such as:
- Meaningful errors for filters referencing invalid/nonexistent callsites.
- GUIs and other visualizations of
tracing
-emitted data that know which queries are valid and invalid. - Testing utilities that allow users to verify whether their intended instrumentation is actually emitted (other alternatives might be preferable).
Proposal
The implementation details might be related to #860. Here are two options that I know of:
- Linker misuse to place all metadata within a single, large array at compile time. A downside of this approach is that it will not work on WASM and doesn't work on MSVC.
- Rewriting tracing's macros to be procedural macros and making use of recently-stabilized const evaluation features. (This was mentioned to me by @oli-obk mentioned this in passing so it's possible I misunderstood!)
Alternatives
- Don't do this.