, 8 tweets, 2 min read Read on Twitter
One neat trick for testing is to test the output of telemetry data.

This is way more low touch than trying to refactor code to make it “testable”.

Many a time, this leads to awkward APIs, encapsulation violations and more.
First, it makes you treat things like loggers, tracers and metrics sinks as dependencies. No more shared global state.

Every test instantiates it’s own logger and passes it to the code being tested. The code will do its thing and 1) result a result or an error 2) emit telemetry.
Second, this enables more airtight encapsulation. You don’t need to make methods/properties public just because you want to test something.

Just check the telemetry output instead. You can maintain clean public APIs that expose just enough to the clients.
Third, it makes sure you add instrumentation to important parts of your code. You can verify that the code functions correctly, and more importantly, that the instrumentation is correct!

Super helpful when debugging to have confidence that the data you’re looking at is correct.
Fourth, passing a context around (even within a single process) allows for testing the latency of various components of code across a wide variety of inputs.

More focused “local stress testing” can help shake out a number of bugs in the hot/critical path of the codebase.
And all of this can just look like unit tests!

It can run as a part of your test harness in CI, without having to make a ton of investment in setting up an integration testing infrastructure.
This isn’t comprehensive by any means, and there are many other forms of testing we should be pursuing.

But purely in terms of testing code functionality, more than small functions to make code “unit testable”, instrumentation APIs can be leveraged a lot more and a lot better.
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Cindy Sridharan
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content 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!