Stream: git-wasmtime

Topic: wasmtime / issue #9799 Allow `wasmtime serve` command's L...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2024 at 02:38):

jzhn opened issue #9799:

Feature

Currently, the wasmtime serve always prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.

Benefit

If wasmtime serve allows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatch

Implementation

Hopefully it's as simple as adding a coupld CLI flags.

Alternatives

No workarounds/alternatives I could think of.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2024 at 02:39):

jzhn edited issue #9799:

Feature

Currently, the wasmtime serve always prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.

Benefit

If wasmtime serve allows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatch

Implementation

Hopefully it's as simple as adding a coupld CLI flags, to make https://github.com/bytecodealliance/wasmtime/blob/9aa048b0eb0caf2bbd85a24bdada33928e42ad3b/src/commands/serve.rs#L141-L149 configurable.

Alternatives

No workarounds/alternatives I could think of.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2024 at 02:42):

jzhn edited issue #9799:

Feature

Currently, the wasmtime serve always prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.

Expected behaviour

logging from http handler in json will be logged by wasmtime serve as-is, without any prefixes.

{"timestamp":"2024-12-12T02:01:04.794485Z","level":"INFO","fields":{"message":"hello world","log.target":"webservice","log.module_path":"webservice","log.file":"webservice/src/lib.rs","log.line":237},"target":"webservice"}
Actual behaviour

handler logs are prefixed with stdout [{req_id}] :: .

stdout [176] :: {"timestamp":"2024-12-12T02:01:04.794485Z","level":"INFO","fields":{"message":"hello world","log.target":"webservice","log.module_path":"webservice","log.file":"webservice/src/lib.rs","log.line":237},"target":"webservice"}

Benefit

If wasmtime serve allows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatch

Implementation

Hopefully it's as simple as adding a coupld CLI flags, to make https://github.com/bytecodealliance/wasmtime/blob/9aa048b0eb0caf2bbd85a24bdada33928e42ad3b/src/commands/serve.rs#L141-L149 configurable.

Alternatives

No workarounds/alternatives I could think of.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 12 2024 at 20:45):

alexcrichton commented on issue #9799:

Sounds reasonable to me to have some CLI flags for this yeah, would you be interested in sending a PR? Perhaps we could start out with a flag to just turn off the prefixes?

view this post on Zulip Wasmtime GitHub notifications bot (Dec 14 2024 at 01:47):

jzhn commented on issue #9799:

@alexcrichton : I'm fairly new to Rust and WASM, but with your encouragement I've created a PR for this. Please take a look and let me know your feedbacks. Thank you!


Last updated: Dec 23 2024 at 12:05 UTC