Backend: Error Monitoring
Go
Java
JS
Python
Ruby
Rust
Backend: Logging
Go
JS
Python
Ruby
Java
Rust
Hosting Providers
Backend: Tracing
Go
Node.js
Python
Rust
Native OpenTelemetry
Fullstack Frameworks
Overview
Self Host & Local Dev
Menu
Edge Runtime
Installation
npm install @highlight-run/next
Vercel Edge Runtime instrumentation
Edge runtime instrumentation is identical for both Page Router and App Router.
- Create a file to export your
EdgeHighlight
wrapper function:
// utils/edge-highlight.config.ts: import { CONSTANTS } from '../../constants' import { EdgeHighlight } from '@highlight-run/next/server' export const withEdgeHighlight = EdgeHighlight({ projectID: CONSTANTS.NEXT_PUBLIC_HIGHLIGHT_PROJECT_ID, })
- Wrap your edge function with
withEdgeHighlight
Page Router
// pages/api/edge-page-router-test.ts import { NextRequest } from 'next/server' import { withEdgeHighlight } from '../../utils/edge-highlight.config.ts' export default withEdgeHighlight(async function GET(request: NextRequest) { console.info('Here: pages/api/edge-page-router-test', request.url) if (request.url.includes('error')) { throw new Error('Error: pages/api/edge-page-router-test (Edge Runtime)') } else { return new Response('Success: pages/api/edge-page-router-test') } }) export const runtime = 'edge'
App Router
// app/edge-page-router-test/route.ts import { NextRequest } from 'next/server' import { withEdgeHighlight } from '../../utils/edge-highlight.config' export const GET = withEdgeHighlight(async function GET(request: NextRequest) { console.info('Here: pages/api/edge-page-router-test', request.url) if (request.url.includes('error')) { throw new Error('Error: pages/api/edge-page-router-test (Edge Runtime)') } else { return new Response('Success: pages/api/edge-page-router-test') } }) export const runtime = 'edge'
Validation
Copy/paste the above code snippet into /app/api/edge-test.ts
and hit the endpoint in your browser or with curl
to watch it work.
Page Router
curl http://localhost:3000/api/edge-page-router-test?error
App Router
curl http://localhost:3000/edge-app-router-test?error