Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/nextjs-otel-example/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
AXIOM_TOKEN="xaat-***"
AXIOM_DATASET="nextjs-otel-example"

GEMINI_API_KEY="******"
41 changes: 41 additions & 0 deletions examples/nextjs-otel-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions examples/nextjs-otel-example/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public-hoist-pattern[]=*require-in-the-middle*
21 changes: 21 additions & 0 deletions examples/nextjs-otel-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Next.js with Opentelemetry example

This is a reference example for using Axiom's AI SDK with Next.js to collect and send traces. The example shows steps for:

- Setting up a NodeSDK tracer under `src/instrumentation.ts` that points to Axiom
- Wrapping AI SDK model under `src/shared/gemini.ts`
- Utilizing `withSpan()` to generate text using Vercel's AI SDK under `app/page.tsx`

## How to use

You will need an Axiom dataset and API key, so gead ahead and create those on [Axiom's Console](https://app.axiom.co/datasets).

Then prepare your environment variables

- Copy the environment file: `cp .env-example .env`
- In the new .env file, set gemini, Axiom API key and dataset name
- Install deps: `pnpm install`
- Run development server `pnpm dev`
- Visit `http://localhost:3000`
- Once the app loads a trace should be sent automatically to Axiom
- Visit Axiom console and navigate to your dataset stream, a list of spans will be visible.
4 changes: 4 additions & 0 deletions examples/nextjs-otel-example/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

module.exports = nextConfig;
Loading