Skip to content

Commit

Permalink
Log malformed message contents in base64 (#272)
Browse files Browse the repository at this point in the history
## Why

Noticed a number of malformed message contents in DD
https://us5.datadoghq.com/logs?query=%22received%20malformed%20msg%22%20%40environment%3Aproduction&agg_m=count&agg_m_source=base&agg_t=count&cols=host%2Cservice%2C%40riverTarget&fromUser=true&messageDisplay=inline&refresh_mode=sliding&storage=hot&stream_sort=desc&viz=stream&from_ts=1726796110823&to_ts=1727400910823&live=true

However we are sending binary messages originally, so we can't tell what
the original contents were once its decoded to a string. We can base64
encode the buffer and then reverse it when trying to debug what is going
wrong with these messages

<!-- Describe what you are trying to accomplish with this pull request
-->

## What changed

<!-- Describe the changes you made in this pull request or pointers for
the reviewer -->

## Versioning

- [ ] Breaking protocol change
- [ ] Breaking ts/js API change

<!-- Kind reminder to add tests and updated documentation if needed -->
  • Loading branch information
bradymadden97 authored Sep 27, 2024
1 parent e33f766 commit b205cdb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions transport/sessionStateMachine/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ export abstract class CommonSession extends StateMachineState {
const parsedMsg = this.options.codec.fromBuffer(msg);

if (parsedMsg === null) {
const decodedBuffer = new TextDecoder().decode(Buffer.from(msg));
this.log?.error(
`received malformed msg: ${decodedBuffer}`,
`received malformed msg: ${Buffer.from(msg).toString('base64')}`,
this.loggingMetadata,
);

Expand Down

0 comments on commit b205cdb

Please sign in to comment.