My Authors
Read all threads
✍️Observability Tools in JavaScript: Improving the JavaScript Developer Experience when Things Go Wrong

Some tips and tools on adding Metrics, Logs, Traces, and Events to your JS/@Nodejs code.

TLDR: Add Observability. Don't log too much. Mostly `debug`.

swyx.io/writing/js-obs…
@nodejs @honeycombio defines it as being able to answer any questions about whats happening on the inside of the system just by observing the outside of the system, without having to ship new code.

We break tools down to Metrics, Logs, Traces, and Events.
Metrics: Bundle Size: swyx.io/writing/js-obs…

We need tools that report and help hold the line on bundle size - see Webpack's tooling and check out @_developit's `compressed-size-action` GitHub action!
Metric: Speed swyx.io/writing/js-obs…

Gradual slowdown can be hard to notice. Get familiar with console.time, the User Timing API, and build reporting tools with memory like @brian_d_vaughn's Progress Estimator ()
Other Metrics: environment info is so key to debugging.

Ask for @trevorbrindlejs' envinfo in every GitHub issue!

swyx.io/writing/js-obs…
Logs: swyx.io/writing/js-obs…

Stream error and app logs. Structure them nicely. Use syslog log levels and `debug`.
Traces: A record of an API call that's made from one part of my application to another swyx.io/writing/js-obs…

`debug` stuff and clean up stack traces with @sindresorhus' clean-stack
Events: An indication of a state change of some type swyx.io/writing/js-obs…

Use `uuid` to generate uuid's and `concordance` to diff values for change events!
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with shawn swyx wang🤗

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!