DEV Community

Cover image for Frontend Observability in Vue Apps with OpenTelemetry
Jakub Andrzejewski
Jakub Andrzejewski

Posted on

Frontend Observability in Vue Apps with OpenTelemetry

As frontend applications become more complex, debugging production issues becomes increasingly difficult.

A user reports: "The page feels slow." or: "The dashboard sometimes freezes."

But when you check your logs... everything looks fine.

The problem is that traditional frontend monitoring often tells you what failed, but not why it happened.

This is where observability comes in. And one of the most popular tools for modern observability is OpenTelemetry.

In this article, we'll explore:

  • What frontend observability is
  • How it differs from traditional monitoring
  • Why OpenTelemetry is becoming the industry standard
  • How to add OpenTelemetry to a Vue application
  • Best practices for collecting useful telemetry

Let's dive in.

πŸ€” What Is Frontend Observability?

Observability is the ability to understand what's happening inside your application by collecting telemetry data.

Typically, this includes:

  • traces
  • metrics
  • logs

Unlike traditional monitoring, observability helps answer questions like:

  • Why is this page slow?
  • Which API request caused the delay?
  • What happened before the error occurred?
  • Which users are affected?

Instead of simply knowing that something failed...

πŸ‘‰ You can understand the entire chain of events that led to the problem.

🟒 Why Is Frontend Observability Important?

Most teams invest heavily in backend observability.

They track:

  • database queries
  • API latency
  • server errors
  • infrastructure metrics

But users interact with the frontend.

And many issues happen before the request even reaches the backend.

For example:

  • slow component rendering
  • blocked main thread
  • failed network requests
  • routing issues
  • third-party script delays

Without frontend observability these problems are often invisible.

🟒 What Is OpenTelemetry?

OpenTelemetry (often called OTel) is an open-source observability framework used to collect and export telemetry data.

It provides a standard way to collect:

  • traces
  • metrics
  • logs

And send them to tools such as:

  • Grafana
  • Jaeger
  • Datadog
  • New Relic
  • Honeycomb
  • Elastic

The biggest advantage? Vendor-neutral instrumentation.

You can change observability providers without rewriting your instrumentation.

🟒 How OpenTelemetry Helps Vue Applications

Imagine a user loads a dashboard.

Several things happen:

Route change
↓
Component mounts
↓
API request starts
↓
Data is fetched
↓
UI renders
Enter fullscreen mode Exit fullscreen mode

Normally these events are disconnected.

With OpenTelemetry you can trace the entire flow.

This helps answer questions like:

  • Which API call slowed down the page?
  • How long did rendering take?
  • Which routes are causing performance issues?

🟒 Setting Up OpenTelemetry in Vue

Let's look at a simplified setup.

Install the required packages:

npm install \
  @opentelemetry/api \
  @opentelemetry/sdk-trace-web \
  @opentelemetry/instrumentation-fetch \
  @opentelemetry/instrumentation-xml-http-request
Enter fullscreen mode Exit fullscreen mode

Basic initialization

import { WebTracerProvider } from '@opentelemetry/sdk-trace-web'

const provider = new WebTracerProvider()

provider.register()
Enter fullscreen mode Exit fullscreen mode

This creates a tracer that can collect telemetry from the browser.

🟒 Creating Custom Traces

One of the most powerful features is custom tracing.

Example:

import { trace } from '@opentelemetry/api'

const tracer = trace.getTracer('vue-app')
Enter fullscreen mode Exit fullscreen mode

Inside a component:

const span = tracer.startSpan('load-users')

try {
  await fetchUsers()
} finally {
  span.end()
}
Enter fullscreen mode Exit fullscreen mode

Now you'll see exactly how long that operation took.

This becomes extremely useful when debugging production issues.

🟒 Tracking Route Performance

Vue Router is another excellent place to add tracing.

Example:

router.beforeEach((to, from, next) => {
  performance.mark('navigation-start')
  next()
})

router.afterEach(() => {
  performance.measure(
    'navigation',
    'navigation-start'
  )
})
Enter fullscreen mode Exit fullscreen mode

Combined with OpenTelemetry exporters, this can help identify slow routes and navigation bottlenecks.

🟒 Monitoring API Requests

Many performance problems originate from network calls.

OpenTelemetry provides automatic instrumentation for:

  • Fetch API
  • XMLHttpRequest

Example:

registerInstrumentations({
  instrumentations: [
    new FetchInstrumentation()
  ]
})
Enter fullscreen mode Exit fullscreen mode

Now requests can automatically generate traces.

You can see:

  • request duration
  • failures
  • dependencies between actions

without manually instrumenting every API call.

πŸ§ͺ Best Practices

  • Instrument critical user flows first
  • Trace important API requests
  • Avoid collecting unnecessary telemetry
  • Sample traces in high-traffic applications
  • Correlate frontend traces with backend traces
  • Monitor route transitions and rendering bottlenecks
  • Focus on actionable insights rather than collecting everything

πŸ“– Learn more

If you would like to learn more about Vue, Nuxt, JavaScript or other useful technologies, checkout VueSchool by clicking this link or by clicking the image below:

Vue School Link

It covers most important concepts while building modern Vue or Nuxt applications that can help you in your daily work or side projects πŸ˜‰

πŸ§ͺ Advance skills

A certification boosts your skills, builds credibility, and opens doors to new opportunities. Whether you're advancing your career or switching paths, it's a smart step toward success.

Check out Certificates.dev by clicking this link or by clicking the image below:

Certificates.dev Link

Invest in yourselfβ€”get certified in Vue.js, JavaScript, Nuxt, Angular, React, and more!

βœ… Summary

Frontend observability helps you understand not just what went wrong, but why it happened.

As applications grow in complexity, logs and error tracking alone are often no longer enough.

OpenTelemetry gives you deeper visibility into your Vue application, helping you identify bottlenecks, improve performance, and deliver a better user experience.

Take care!
And happy coding as always πŸ–₯️

Top comments (0)