Repository navigation
None of the AI auto-instrumentations work with Sentry Bun #19696
Copy link
Copy link
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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/[email protected]
@langchain/[email protected]
@langchain/[email protected]
@langchain/[email protected]
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Mar 8, 2026
JS-1890
s1gr1d commentedon Mar 9, 2026
Automatic instrumentation is currently not supported in Bun (also check out the tracking issue here).
You can also manually instrument the package by wrapping it like it's documented here: https://docs.sentry.io/platforms/javascript/configuration/integrations/google-genai/
We'll update the docs on that for Bun.
vjancik commentedon Mar 9, 2026
Thank you! I didn't find the manual instrumentation option in the Bun docs.
[-]None of the auto-instrumentations work with Sentry Bun[/-][+]None of the AI auto-instrumentations work with Sentry Bun[/+]s1gr1d commentedon Mar 9, 2026
Yes, it's missing there but I created a PR to update that: getsentry/sentry-docs#16843
Update: Docs are updated now: https://docs.sentry.io/platforms/javascript/guides/bun/configuration/integrations/google-genai/
docs(js): Differentiate manual and automatic AI instrumentation (#16843)
andreiborza commentedon May 21, 2026
Closing this as docs are now clearer about it.