cloudflare / foundations

Cloudflare's Rust service foundations library.
https://blog.cloudflare.com/introducing-foundations-our-open-source-rust-service-foundation-library
BSD 3-Clause "New" or "Revised" License
1.25k stars 51 forks source link

Add ability for logging to record tracing span log entries #59

Open LloydW93 opened 1 month ago

LloydW93 commented 1 month ago

In large environments with separate logging and tracing pipelines, identifying pertinent log information for a trace can involve searching in an entirely different store, which may be subject to its own sampling and rate limiting. For these situations, the log lines generate specifically whilst the traced action is executed are particularly high value in providing additional context.

This change adds trace emission options for the logging module, which allow enabling emitting logs from traces at a separately specified verbosity level, which can be changed the same was as we can with set_verbosity.

To fully specify log fields, add_span_log_fn is added as a macro to the tracing module, at a cost of losing the full abstraction over rustracing.

Fixes #58

inikulin commented 1 month ago

@LloydW93 I'm not sure I understand the motivation behind #58 (see comment there) and what this PR tries to do