Repository navigation
feat: add flatten: 'otel' and otelAttributesFormat for winston-transport 0.29+ (2.3.0) - #155
Merged
Merged
Conversation
…ort 0.29+
From 0.29, @opentelemetry/winston-transport lifts an `err`/`error` value off
the record and hands it to the logs SDK as the exception, which keeps only
name, message, stack and a cause's message. So:
- `flatten: true` stringifies the error first, and the SDK records the whole
JSON as one `exception.message`, with no type or stack trace.
- No flattening records the exception but drops the rest of the error
(status, provider data, cause chain), and 0.32+ sends other objects as
nested maps that Log Analytics does not index.
`otelAttributesFormat` keeps the error an object with only the fields the
SDK reads, moves the rest to `<key>Detail` as JSON (code too, since the SDK
prefers a truthy code over name for exception.type), and stringifies every
other object value; a Date becomes its unquoted ISO string. It can sit on
the transport, keeping other transports nested, or be applied for every
transport with `createLogger({ flatten: 'otel' })` — the only option with
WinstonInstrumentation, which constructs its transport without a format.
`flatten: true` is unchanged and documented as the mode for transports
before 0.29. The README gains a transport-line matrix. A new spec drives
the real transport at 0.27, 0.31 and 0.34 (npm aliases) into the logs SDK
and asserts the exported attributes, including the two failure modes above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands #154 on
main. #154 was approved and merged, but into its stacked basefix/date-metadata— it was merged two minutes after #153 and before GitHub retargeted it — so its commit never reachedmainand 2.3.0 was never published (latestis 2.2.1).This branch has exactly the tree #154 merged (
git diff origin/fix/date-metadata origin/feat/otel-attributes-formatis empty); againstmainit is that one commit. The description, rationale and test plan are on #154.Test plan
npm run build,npm run audit,npm test(185 tests, including the real-transport matrix at 0.27, 0.31 and 0.34) all passed theremain, so feat: add flatten: 'otel' and otelAttributesFormat for winston-transport 0.29+ (2.3.0) #154 never had it)