What broke when I moved Grafana Faro to OpenTelemetry JS 3.0
TL;DR: I opened the three PRs that move Grafana Faro's web SDK onto OpenTelemetry JS SDK 3.0. The version bump was the easy part. What took the time was a deep import the new exports maps reject, and then the tests. Jest was quietly running the Node build, and a disabled XHR instrumentation turned out to still be making spans. All three PRs are open and waiting on review. Why Faro had to move at…
In this report, I will detail the challenges faced when moving Grafana Faro to OpenTelemetry JS 3.0. The version upgrade was relatively straightforward, but the real work involved deep import adjustments, dealing with export maps, and testing.
Grafana Faro was on version 2.x, 0.223, and API 1.9, while OpenTelemetry JS SDK 3.0, experimental 0.300, and API 1.10 were released on October 20. These new versions are only compatible with each other, so users cannot mix and match different versions. Moving Grafana Faro to the new SDK was necessary due to the contrib browser instrumentations already moving to core ^3.0.0.
Three pull requests (PRs) were created to facilitate this transition, with the version bump being the easiest part. The first two PRs, #2358 and #2363, made changes to the tracing setup and removed deep imports into OTel packages, which could be merged at any time on the 2.x branch. The final PR, #2364, focused on the actual 3.0 / 0.300 / 1.10 bump and required more attention due to potential compatibility issues.
The main challenge was the imports into the OTel packages, especially the OTLP transformer. Faro had direct imports into build/src of this package, but with the new SDK, these imports failed because they weren't listed in the exports map. To resolve this, the OTLP types were moved to @grafana/faro-core, and the exporter was updated to use the public JsonTraceSerializer.
Another issue was a disabled XHR instrumentation that was still making spans. This was caused by Jest quietly running the Node build, leading to incorrect test results. To address this, a Jest resolver was added to test the correct code.
Finally, the tracing IIFE size was reduced from 90,474 to 87,299 bytes minified by dropping a package that was no longer needed. The exports map issue was resolved by moving the OTLP types to @grafana/faro-core and updating the exporter to use JsonTraceSerializer.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.