Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Commit 382b9bb

Browse files
committed
feat: add ELASTIC_APM_PAYLOAD_LOG debug option
1 parent be7bb12 commit 382b9bb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ Destroy the `client`. After this call, the client has ended and
190190
subsequent calls to `sendSpan()`, `sendTransaction()`, `sendError()`,
191191
`flush()`, or `end()` will result in an error.
192192

193+
## Debugging
194+
195+
To see what data is being sent to the APM Server, use the environment
196+
variable `ELASTIC_APM_PAYLOAD_LOG` to speicfy a log file, e.g:
197+
198+
```
199+
ELASTIC_APM_PAYLOAD_LOG=/tmp/payload.ndjson
200+
```
201+
193202
## License
194203

195204
MIT

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ function Client (opts) {
7777

7878
pump(this._stream, this._chopper)
7979

80+
if (process.env.ELASTIC_APM_PAYLOAD_LOG) {
81+
const logFile = require('fs').createWriteStream(process.env.ELASTIC_APM_PAYLOAD_LOG, {flags: 'a'})
82+
pump(this._stream, logFile)
83+
}
84+
8085
this._index = clients.length
8186
clients.push(this)
8287
}

0 commit comments

Comments
 (0)