Skip to content

Conversation

blarghmatey
Copy link
Member

What are the relevant tickets?

N/A

Description (What does it do?)

Adds OTEL integration for the NextJS app so that we can capture tracing data for it in Grafana.

How can this be tested?

Run the app and verify that it starts generating trace spans

Additional Context

We have OTel tracing enabled in the Django layer but not yet in the NextJS. Adding it to the frontend will help provide more end-to-end context of requests throughout our application layers.

@blarghmatey blarghmatey requested a review from Copilot August 5, 2025 15:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds OpenTelemetry (OTEL) integration to the NextJS frontend application to enable distributed tracing capabilities, providing better observability alongside the existing Django backend tracing.

  • Integrates Vercel's OTEL package for NextJS instrumentation
  • Adds OTEL initialization to the existing instrumentation setup
  • Includes necessary OpenTelemetry dependencies for comprehensive tracing

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
frontends/main/src/instrumentation.ts Adds OTEL registration with service name configuration
frontends/main/package.json Adds OpenTelemetry and Vercel OTEL dependencies

@ChristopherChudzicki
Copy link
Contributor

ChristopherChudzicki commented Sep 4, 2025

@blarghmatey I tried to get this to work locally today. There seems to be some interaction between Sentry and @vercel/otel going on. After failing to get data into into otel-lgtm locally, I tried simply using ConsoleSpanExporter:

export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    await import("../sentry.server.config")
  }

  const serviceName = process.env.OTEL_SERVICE_NAME || "mitlearn-frontend"
  registerOTel({ serviceName, traceExporter: new ConsoleSpanExporter() })
}

This logs nothing. But when the sentry code is removed, it starts behaving as expected. I haven't looked into the conflict too much, but did notice these two issues on Sentry's github:

As a first / separate step, probably worth updating Sentry's SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants