[WIP] new: Support structured tracing logs.#876
Conversation
| http = ["ureq"] # enables extism_http_request | ||
| wasmtime-default-features = [ | ||
| 'wasmtime/default', | ||
| default = [ |
zshipko
left a comment
There was a problem hiding this comment.
this is neat! it looks like a great improvement. i will test it out a little more at some point today, but i don't see why not to move forward with this since it won't immediately require PDK changes beyond what you've done in the rust-pdk
| Ok(buf) => { | ||
| use tracing_dynamic::EventFactory; | ||
|
|
||
| let log = if buf.starts_with('{') { |
There was a problem hiding this comment.
nice, so this makes it backward compatible? i think that was my only real concern about a change like this
There was a problem hiding this comment.
ya it should support a message string, and the event as a json object
|
@zshipko I haven't tested this yet because I can't compile the project: |
|
@milesj - I haven't seen that before, is this using It looks like something related to the maturin bindings, you should be able to at least build/test the runtime if you run |
|
This is just |
|
@zshipko any suggestions on how I could test this? |
Sibling PR to extism/rust-pdk#81
Extism has logging/tracing support currently through explicit macro usage, but what it doesn't support is inheriting
tracinglogs that come from 3rd-party crates. Right now all those messages are lost, which is a huge bummer.I wanted to figure it out if inheriting these 3rd-party logs is even possible... and it is! Turns out you can set
tracing::set_global_defaultin WASM to read these logs, and then pipe them to extism. Here's an example I've been experimenting with: https://github.com/moonrepo/proto/blob/master/crates/warpgate-pdk/src/tracing.rs#L98While this works, there is a major downside, and that is that field information is lost. Extism only supports the message string, so to pipe field data through, you need to include it in the message. This results in ugly logs, as seen here (notice the
extism::pdklines):Solution
So in this PR, I wanted to figure out a way to support this field data, and a custom target (to override
extism::pdk). I'm doing this by introducing a new struct,TracingLog, that includes this information. I've stored this struct inextism-convertso that it can also be used in the PDK (there will be a sibling PR to this one).I then use the
tracing-dynamiccrate (https://github.com/BrynCooke/tracing-dynamic) to send the event, because it's currently impossible to set dynamic fields on an event (why tracing why???).