📬 A demo implementation for the log clutter issue discussed in #672.
It needs more work (docs, tests, better env var parsing)
✍️ Description of changes:
Reuse AWS_LAMBDA_LOG_FORMAT to specify if the root span should not be created.
E.g. AWS_LAMBDA_LOG_FORMAT=no-span or AWS_LAMBDA_LOG_FORMAT=json,no-span
The TracingLayer is added by default and not added if AWS_LAMBDA_LOG_FORMAT contains no-span.
Impact
the change is backward compatible
nothing changes for existing implementations
minimal performance penalty for reading an env var
no code changes are needed to change the log format
This last point allows using different log formats in different environments without code changes.
Examples
Including the root span
INFO Lambda runtime invoke{requestId="local-request-id" xrayTraceId="Root=0-00000000-000000000000000000000000;Parent=0000000000000000;Sampled=0;Lineage=00000000:0"}: With global default provider
INFO Lambda runtime invoke{requestId="local-request-id" xrayTraceId="Root=0-00000000-000000000000000000000000;Parent=0000000000000000;Sampled=0;Lineage=00000000:0"}: Command received: echo
ERROR Lambda runtime invoke{requestId="local-request-id" xrayTraceId="Root=0-00000000-000000000000000000000000;Parent=0000000000000000;Sampled=0;Lineage=00000000:0"}: "Error"
No root span (the main goal of this PR)
INFO With global default provider
INFO Command received: echo
ERROR "Error"
@calavera , thank you. It is very embarrassing how I missed it. The solution was hiding in the plain sight. Sorry for wasting so much of your time on this.
📬 A demo implementation for the log clutter issue discussed in #672. It needs more work (docs, tests, better env var parsing)
✍️ Description of changes:
Reuse
AWS_LAMBDA_LOG_FORMAT
to specify if the root span should not be created. E.g.AWS_LAMBDA_LOG_FORMAT=no-span
orAWS_LAMBDA_LOG_FORMAT=json,no-span
The
TracingLayer
is added by default and not added ifAWS_LAMBDA_LOG_FORMAT
containsno-span
.Impact
This last point allows using different log formats in different environments without code changes.
Examples
Including the root span
No root span (the main goal of this PR)
Root span + JSON
No root span + JSON
🔏 By submitting this pull request
cargo +nightly fmt
.cargo clippy --fix
.