Migrating from gather.town?
Get a discount!
A laptop showing the new 1.24 version of WorkAdventure.

Synthetic Monitoring (E2E) with Playwright

July 30, 2024
A laptop showing the new 1.24 version of WorkAdventure.

Synthetic Monitoring?

Monitoring your website in production is crucial to ensure that it remains available and performs as expected.
If anything fails, you want to be notified as soon as possible.

Most monitoring tools (like Uptime Robot, Uptime Kuma, Oh Dear, …) rely on pinging your website at regular intervals to check if it’s up and running.
Typically, those tools will check if your website returns a 200 status code when they send a GET request to your website.

While this is a good start, it can be insufficient to detect all issues when your website becomes more complex.

When simple monitoring tools fail to detect issues, you will want to reproduce as closely as possible the behaviour of your users to detect issues that might be specific to them. This is what Synthetic Monitoring is about.

Why Synthetic Monitoring Became My Focus

At WorkAdventure, we recently went through a challenging experience during an upgrade. We had to migrate our database to
a new version, and this migration took a long time. During this time, we had a version mismatch between the services that
were already migrated and the services that were still waiting for the migration.

Each individual service was technically operational, but the whole application was down because of the version mismatch.
All our monitors were green, despite the application being down for several hours (!)

Hopefully, we did this migration during the night, so the impact was limited. But it was a wake-up call for me.

I started looking for tools that could help me detect this kind of issue in the future. I discovered Synthetic Monitoring
and started to look for tools that could help me with that. I even started working on a tool based on Puppeteer that
would reproduce the behaviour of a normal user on our application. Writing the tool with Puppeteer API was tedious, and
I soon realized I was only duplicating the work of the Playwright tests that are running in our CI/CD pipeline.

Suddenly, it struck me: I could use Playwright to do Synthetic Monitoring!

And so is born the Playwright Synthetic Monitoring project.

Introducing My Project: Playwright Synthetic Monitoring

Playwright Synthetic Monitoring is a Docker image that monitors your website uptime and functionality by running
end-to-end (E2E) Playwright tests at regular interval, directly on your production website.

What It Offers

  • Regular Interval Testing: It runs Playwright tests every 5 minutes by default, ensuring that issues are detected promptly.
  • HTTP Endpoints for Monitoring: It provides a Prometheus “/metrics” endpoint for scraping test results and a “/healthcheck” endpoint for uptime tracking, which returns HTTP 200 for success and HTTP 500 for failures. The “/” route will display a nice HTML webpage with a human readable status.
  • Error Reporting: A “/last-error” webpage details the last failed Playwright report, helping quickly identify and resolve issues.

Its Limitations

While my Playwright Synthetic Monitoring project excels in simulating user interactions and detecting issues that might
be missed by traditional monitoring, it does not include built-in alerting mechanisms. It is designed to complement,
not replace, other forms of monitoring.

The idea is to run Playwright Synthetic Monitoring alongside your existing monitoring tools. You can point your traditional
monitoring tool to the /healthcheck endpoint to get alerted when something goes wrong.

Conclusion

While traditional monitoring tools are essential for detecting issues with your website, they can sometimes miss more subtle issues that only a user would encounter. Synthetic Monitoring with Playwright fills this gap by simulating user
interactions and detecting issues that might be missed by traditional monitoring.

Use it if you feel traditional monitoring tools are not enough to detect all issues with your website.
Be aware that it requires a bit more resources that traditional monitoring tools (as it will simulate a real user)

Finally, there are other tools available that provide similar functionality. If you are looking for an out-of-the-box SaaS solution, you might want to check out tools like Hyperping.

Playwright Synthetic Monitoring is open-source and available on GitHub.

Two people speaking

Get in touch ?

We are building awesome worlds for companies.

Want to talk with a virtual world expert?Β