How to Build an Open Telemetry SDK in 7 Minutes

This ad is not shown to multipass and full ticket holders
JSNation US
JSNation US 2025
November 17 - 20, 2025
New York, US & Online
JS stars in the US biggest planetarium
Learn More
In partnership with Focus Reactive
Upcoming event
JSNation US 2025
JSNation US 2025
November 17 - 20, 2025. New York, US & Online
Learn more
Bookmark
Rate this content

In this talk, I'll provide an overview of the fundamental building blocks required to develop a fullstack observability SDK with minimal friction for users. We'll look into OpenTelemetry-compatible instrumentation techniques for error monitoring, tracing, and logging. Drawing from our open-source development experiences at Sentry, I'll share valuable insights and learnings, while primarily focusing on the high-level challenges encountered when creating a JavaScript SDK.

This talk has been presented at JSNation 2025, check out the latest edition of this JavaScript Conference.

FAQ

OpenTelemetry is an open source framework that provides a standardized set of tools and APIs for collecting, processing, and exporting telemetry data.

Observability is important because it allows you to gain insights and take actions based on the telemetry data emitted by your application, helping you to fix issues effectively.

The three types are: uninstrumented apps (which emit no data), manually instrumented apps (where developers decide which signals to send), and automatically instrumented apps (which gather telemetry data automatically).

Automatic instrumentation works by using a technique such as monkey patching or JS proxy to modify functions or modules, allowing telemetry signals to be collected and sent to the backend automatically.

Monkey patching is a technique where a module or function is modified to extend its functionality without altering its core functionality during runtime, enabling telemetry data collection.

OpenTelemetry benefits from community-maintained libraries because it provides a standardized way of doing things, allowing easy integration and mixing of community-based libraries with custom instrumentations.

The 'register instrumentations' call in OpenTelemetry is used to specify an array of instrumentations, such as HTTP and express, including custom OpenTelemetry instrumentations, enabling standardized observability.

The advantage of using OpenTelemetry in a dynamic JavaScript ecosystem is that it provides a standardized way of instrumenting libraries and frameworks, allowing developers to pick and use parts as needed.

Developers should ensure they can maintain the SDKs they build, selecting the right tools to use, as building SDKs can be complex.

The key takeaway is that observability is crucial because it enables you to see and fix what is actually happening in your application.

Charly Gomez
Charly Gomez
6 min
12 Jun, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Showcasing adding observability with OpenTelemetry. Benefits of extensive telemetry data for insights. Contrasting uninstrumented, manual, and automatic instrumented apps. Example of instrumenting fetch calls for telemetry signals. Technique for modifying functions without core updates. Using JS proxy as a modern approach for patching. OpenTelemetry standardizes instrumentation with APIs and tools. Example of setting up OpenTelemetry with instrumentations.

1. Adding Observability with OpenTelemetry

Short description:

Showcasing adding observability with OpenTelemetry. Benefits of extensive telemetry data for insights. Contrasting uninstrumented, manual, and automatic instrumented apps. Example of instrumenting fetch calls for telemetry signals.

I want to show you how you can add observability to your application with just one line of code. Who has worked with OpenTelemetry before? Maybe a quick show of hands? Oh, yeah, not too many, but still quite a few. OpenTelemetry is an open source framework which provides a standardized set of tools and APIs for collecting, processing, and exporting telemetry data.

Why do we need that? There is the notion that the more information you have, the closer you are to the truth and the more wisdom and power you gain from it. Mapped to OpenTelemetry or to observability, this would mean that the more signals your application is emitting, the more aggregated telemetry data you have and the more insights and actions you can take out of it. Let's look at three examples. First one would be an uninstrumented app. Basically a black box because it doesn't emit anything. Second would be a manually instrumented app where you, the developer, is deciding which signals you want to send to the observability backend.

And third is kind of the sweet spot where we have an automatically instrumented app, meaning you just write the application code and some library or SDK is magically gathering the telemetry data behind the scenes and sending it to your backend. Let's look into this a bit more in detail with the example of fetch. An uninstrumented fetch call would be a basic fetch call. It fetches data and then life goes on. Manually instrumented fetch call in the case of OpenTelemetry would look something like this. You have a tracer which is an OTEL component which starts a span.

A span is just a word for a single operation that is timed and that measures things. So here we start the span, we call fetch, and whenever the fetch call ends, we end the span and that's how we measure it. You see there's quite a lot of code to maintain. So let's look at the sweet spot where we want to land. An automatically instrumented app where we just import our SDK, we call init, and then we use fetch as we have always done before. Let's maybe look behind the scenes of this init call. How can we behind the scenes make fetch emit these telemetry signals? We do this by using a technique called monkey patching which many of you are probably aware of.

2. Modifying Functions with OpenTelemetry

Short description:

Technique for modifying functions without core updates. Using JS proxy as a modern approach for patching. OpenTelemetry standardizes instrumentation with APIs and tools. Example of setting up open telemetry with instrumentations.

It is a technique where we modify a module or a function and we extend the functionality without updating the core functionality of it during runtime. In the case of fetch, this could look something like this. Since we're still in JavaScript world, we can basically do what we want. So we just take the global fetch, store it away, and then override the global fetch with the tracer that we've seen earlier. So every time in the user code we call fetch now, it will be traced automatically.

A more modern way of doing this would be to use a JS proxy which you can think of basically as a middleman between the function or module you want to patch and the code that is calling it. How does OTL come into play here? As I mentioned earlier, open telemetry provides a standardized way of doing things. By this, I mean tools and APIs like this instrumentation base class that you can see on top which we just extend for our custom instrumentation.

There is some scaffolding around, so we want to specify which module we want to patch. We can specify a version range. But then the important part is marked in red here, where we basically do what we've just seen before, monkey patching, a specific functionality of a module that we want to trace. So, coming back to our init call. This would be a very basic example on how open telemetry setup could look like. It includes several building blocks. It's not too important what we're using here at the moment, but the important thing is the register instrumentations call that is marked in red. Here you see we provide an array of instrumentations.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Multithreaded Logging with Pino
JSNation Live 2021JSNation Live 2021
19 min
Multithreaded Logging with Pino
Top Content
Today's Talk is about logging with Pino, one of the fastest loggers for Node.js. Pino's speed and performance are achieved by avoiding expensive logging and optimizing event loop processing. It offers advanced features like async mode and distributed logging. The use of Worker Threads and Threadstream allows for efficient data processing. Pino.Transport enables log processing in a worker thread with various options for log destinations. The Talk concludes with a demonstration of logging output and an invitation to reach out for job opportunities.
Observability for Microfrontends
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
Observability for Microfrontends
Premium
Microfrontends follow the microservices paradigm and observability is crucial for debugging runtime production issues. Error boundaries and tracking errors help identify and resolve issues. Automation of alerts improves incident response. Observability can help minimize the time it takes to understand and resolve production issues. Catching errors from the client and implementing boundaries can be done with tools like OpenTelemetry.
Observability with diagnostics_channel and AsyncLocalStorage
Node Congress 2023Node Congress 2023
21 min
Observability with diagnostics_channel and AsyncLocalStorage
Observability with Diagnostics Channel and async local storage allows for high-performance event tracking and propagation of values through calls, callbacks, and promise continuations. Tracing involves five events and separate channels for each event, capturing errors and return values. The span object in async local storage stores data about the current execution and is reported to the tracer when the end is triggered.
How Grafana Uses React to Power the World of Observability
React Summit 2023React Summit 2023
7 min
How Grafana Uses React to Power the World of Observability
Watch video: How Grafana Uses React to Power the World of Observability
Grafana uses React to power its open source platform, leveraging its vast ecosystem, improved performance, and community contributions. The choice of state management tool depends on the team's problem space. React Hooks have posed challenges but have also been a powerful tool for developers. The new Scenes library simplifies development and reduces the learning curve. Despite challenges, React remains a powerful tool for complex frontends, and Grafana will continue to use it.
GraphQL Observability
GraphQL Galaxy 2020GraphQL Galaxy 2020
8 min
GraphQL Observability
This Talk discusses how to tool Apollo server with open tracing for observability. OpenTracing is a vendor-agnostic format that works well with distributed systems in microservices. It allows for converting GraphQL tracing data to a vendor-agnostic format and enriching information from GraphQL servers. If providers support OpenTracing, it can be easily integrated.
Creating an innovation engine with observability
Node Congress 2023Node Congress 2023
27 min
Creating an innovation engine with observability
Baseline provides observability for serverless architectures and has created an innovation engine within their team. They measure team performance using Dora metrics and the Accelerate book. Baseline emphasizes the importance of foundations, streamlined testing, and fast deployment. They practice observability-driven development and incorporate observability as part of their development lifecycle. Baseline believes in building a culture that fosters ownership and democratizes production.

Workshops on related topic

Scaling Databases For Global Serverless Applications
Node Congress 2022Node Congress 2022
83 min
Scaling Databases For Global Serverless Applications
Workshop
Ben Hagan
Ben Hagan
This workshop discusses the challenges Enterprises are facing when scaling the data tier to support multi-region deployments and serverless environments. Serverless edge functions and lightweight container orchestration enables applications and business logic to be easily deployed globally, often leaving the database as the latency and scaling bottleneck.
Join us to understand how PolyScale.ai solves these scaling challenges intelligently caching database data at the edge, without sacrificing transactionality or consistency. Get hands on with PolyScale for implementation, query observability and global latency testing with edge functions.
Table of contents- Introduction to PolyScale.ai- Enterprise Data Gravity- Why data scaling is hard- Options for Scaling the data tier- Database Observability- Cache Management AI- Hands on with PolyScale.ai