Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only send 2 MiB of log data in diagnose report #415

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

tombruijn
Copy link
Member

Don't send too much log file data. We previously decided upon 2 MiB of
data for the appsignal.log in the Ruby gem, so apply that in the Node.js
integration too.

I wrote the reading of this data in a sync way, with Sync functions
from the fs module. I could not get it to work with promises and async
without rewriting the entire script to be async, which seemed like a lot
of work for this change.

This sync approach is less safe I think, because we need to close the
open file manually. To make it more safe I've added the file closing to
the finally statement that triggers in the try-block regardless if an
error occurs in the try-block. The finally-block is like an ensure-block
in Ruby.

Closes #413

@tombruijn tombruijn added the bug label Jul 15, 2021
@tombruijn tombruijn self-assigned this Jul 15, 2021
@tombruijn tombruijn force-pushed the read-limited-file-contents branch 2 times, most recently from fc88817 to 24edfd5 Compare July 15, 2021 14:13
@tombruijn tombruijn marked this pull request as ready for review July 15, 2021 14:18
Don't send too much log file data. We previously decided upon 2 MiB of
data for the appsignal.log in the Ruby gem, so apply that in the Node.js
integration too.

I wrote the reading of this data in a sync way, with `Sync` functions
from the `fs` module. I could not get it to work with promises and async
without rewriting the entire script to be async, which seemed like a lot
of work for this change.

This sync approach is less safe I think, because we need to close the
open file manually. To make it more safe I've added the file closing to
the `finally` statement that triggers in the try-block regardless if an
error occurs in the try-block. The finally-block is like an ensure-block
in Ruby.

Closes #413
@tombruijn tombruijn force-pushed the read-limited-file-contents branch from 24edfd5 to 068e2fb Compare July 15, 2021 14:26
@tombruijn tombruijn merged commit baa2b7f into main Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diagnose report reads whole appsignal.log file
2 participants