Skip to content

None of the AI auto-instrumentations work with Sentry Bun #19696

@vjancik

Description

@vjancik

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/bun

SDK Version

10.42.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

instrumentation.ts

import * as Sentry from '@sentry/bun';

if (!process.env.SENTRY_URL) {
    throw new Error('SENTRY_URL environment variable is not set');
}

Sentry.init({
    dsn: process.env.SENTRY_URL,
    // Send structured logs to Sentry
    enableLogs: true,
    // Tracing
    tracesSampleRate: 1.0, // Capture 100% of the transactions
    debug: true,
    integrations: [
        // Sentry.googleGenAIIntegration(),
        // Sentry.langChainIntegration(),
        // Sentry.langGraphIntegration(),
    ]
});

// This works so SENTRY_URL and project are setup correctly
// Sentry.logger.info("Sentry instrumentation initialized");

test.ts

/**
 * Minimal @google/genai test script for validating Sentry Google_GenAI instrumentation.
 *
 * Run via: bun run sentry:test
 *
 * Uses the same model as the general agent. Does NOT go through LangChain,
 * so a successful trace in Sentry means the issue is LangChain-specific.
 */
// import '../../src/infrastructure/instrumentation/sentry/instrumentation.ts';
import { GoogleGenAI } from "@google/genai";
import * as Sentry from "@sentry/bun";

if (!process.env.GOOGLE_API_KEY) {
    throw new Error("GOOGLE_API_KEY is not set");
}

const genai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY });

console.log("Sending generateContent request...");

const response = await genai.models.generateContent({
    model: "gemini-3-flash-preview",
    contents: "Reply with exactly one word: hello",
});

console.log("Response:", response.text);

// Flush Sentry before the process exits so traces/spans are not dropped.
console.log("Flushing Sentry...");
await Sentry.flush(5000);
console.log("Done.");

Steps to Reproduce

bun run --preload instrumentation.ts test.ts
Or you can uncomment the instrumentation.ts import in test.ts and just do bun run test.ts

Expected Result

GenAI Traces should appear in the dashboard.
I also tried with Langchain and Langgraph, also didn't get picked up in my project.

Actual Result

$ bun --preload ./src/infrastructure/instrumentation/sentry/instrumentation.ts scripts/dev/sentry-genai-test.ts
Sentry Logger [log]: Initializing Sentry: process: 156874, thread: main.
Sentry Logger [log]: Cleared AI provider skip registrations
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: NodeFetch
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: ProcessSession
Sentry Logger [log]: Integration installed: BunServer
Sentry Logger [log]: Integration installed: Express
Sentry Logger [log]: Integration installed: Fastify
Sentry Logger [log]: Integration installed: Graphql
Sentry Logger [log]: Integration installed: Hono
Sentry Logger [log]: Integration installed: Mongo
Sentry Logger [log]: Integration installed: Mongoose
Sentry Logger [log]: Integration installed: Mysql
Sentry Logger [log]: Integration installed: Mysql2
Sentry Logger [log]: Integration installed: Redis
Sentry Logger [log]: Integration installed: Postgres
Sentry Logger [log]: Integration installed: Prisma
Sentry Logger [log]: Integration installed: Hapi
Sentry Logger [log]: Integration installed: Koa
Sentry Logger [log]: Integration installed: Connect
Sentry Logger [log]: Integration installed: Tedious
Sentry Logger [log]: Integration installed: GenericPool
Sentry Logger [log]: Integration installed: Kafka
Sentry Logger [log]: Integration installed: Amqplib
Sentry Logger [log]: Integration installed: LruMemoizer
Sentry Logger [log]: Integration installed: LangChain
Sentry Logger [log]: Integration installed: LangGraph
Sentry Logger [log]: Integration installed: VercelAI
Sentry Logger [log]: Integration installed: OpenAI
Sentry Logger [log]: Integration installed: Anthropic_AI
Sentry Logger [log]: Integration installed: Google_GenAI
Sentry Logger [log]: Integration installed: PostgresJs
Sentry Logger [log]: Integration installed: Firebase
Sentry Logger [log]: SDK initialized from ESM
Sentry Logger [log]: @opentelemetry/api: Registered a global for diag v1.9.0.
Sentry Logger [log]: @opentelemetry/api: Registered a global for trace v1.9.0.
Sentry Logger [log]: @opentelemetry/api: Registered a global for propagation v1.9.0.
Sentry Logger [log]: @opentelemetry/api: Registered a global for context v1.9.0.
Sentry Logger [log]: @sentry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook {
  module: "https",
}
Sentry Logger [log]: @opentelemetry_sentry-patched/instrumentation-http Applying instrumentation patch for nodejs core module on require hook {
  module: "https",
}
Sending generateContent request...
Response: Hello
Flushing Sentry...
Sentry Logger [log]: SpanExporter exported 0 spans, 0 spans are waiting for their parent spans to finish
Sentry Logger [log]: Flushing outcomes...
Sentry Logger [log]: No outcomes to send
Done.
Sentry Logger [log]: Flushing outcomes...
Sentry Logger [log]: No outcomes to send

Nothing is emitted.

Additional Context

Library version:
@google/genai@1.44.0
@langchain/core@1.1.30
@langchain/google@0.1.5
@langchain/langgraph@1.2.0

Bun version: 1.3.10
System: Ubuntu 25.10 (Linux 6.17.0-14-generic)

Very old maybe unrelated issue:
#14202

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions