Skip to content

Commit 5a85ff2

Browse files
committed
Adding bun and node llms.txt for testing
1 parent 716f321 commit 5a85ff2

File tree

3 files changed

+261
-4
lines changed

3 files changed

+261
-4
lines changed

public/llms.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ Sentry llms.txt
22

33
This llmx.txt focuses on platform specific configuration options for the major sdks, linked below. AI sdks should parse these paths to access the framework specific llm instructions.
44

5-
[Nextjs](/platforms/javascript/guides/nextjs/llms.txt)
6-
[React](/platforms/javascript/guides/react/llms.txt)
7-
[JavaScript](/platforms/javascript/common/llms.txt)
8-
[Python](/platforms/python/llms.txt)
5+
[nextjs](/platforms/javascript/guides/nextjs/llms.txt)
6+
[react](/platforms/javascript/guides/react/llms.txt)
7+
[javaScript](/platforms/javascript/common/llms.txt)
8+
[python](/platforms/python/llms.txt)
9+
[bun](/platforms/bun/llms.txt)
10+
[node](/platforms/node/llms.txt)

public/platforms/bun/llms.txt

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Sentry and Bun LLM Rules
2+
3+
You are an expert in application architecture and the configuration of observability tools like Sentry. Ensure you are following these instructions, while taking into account the user's request.
4+
5+
Always ensure you are installing Sentry using `bun add @sentry/bun@latest`. The latest package should always be used unless explicitly told otherwise.
6+
7+
## Configuration examples
8+
9+
These examples should be used to configure the different Sentry functionality in Bun applications. Use these as the default configuration, factoring in the user's requests.
10+
11+
### Sentry Setup (applies to all configurations)
12+
13+
Sentry should be initialized as early as possible in your application's lifecycle. Create a file named `instrument.js` that imports and initializes Sentry:
14+
15+
```javascript
16+
import * as Sentry from "@sentry/bun";
17+
18+
// Initialize Sentry before importing any other modules
19+
Sentry.init({
20+
dsn: "<sentry dsn>",
21+
22+
// Enable tracing to capture 100% of transactions
23+
// Recommend adjusting this value in production
24+
tracesSampleRate: 1.0,
25+
26+
// Set tracePropagationTargets for which URLs trace propagation should be enabled
27+
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
28+
});
29+
```
30+
31+
Then import this file at the very beginning of your main application file:
32+
33+
```javascript
34+
// Import this first!
35+
import "./instrument";
36+
37+
// Now import other modules
38+
import http from "http";
39+
40+
// Your application code goes here
41+
```
42+
43+
### Error Tracking and Exception Catching
44+
45+
Instrument errors throughout the application using the following approaches:
46+
47+
```javascript
48+
// Explicitly capture an exception
49+
try {
50+
throw new Error("Example error");
51+
} catch (e) {
52+
Sentry.captureException(e);
53+
}
54+
55+
// Capture a custom message
56+
Sentry.captureMessage("Something went wrong", "error");
57+
58+
// Add extra context to the error
59+
Sentry.configureScope((scope) => {
60+
scope.setTag("page_locale", "de-at");
61+
scope.setUser({ id: '123', email: '[email protected]' });
62+
scope.setExtra("character_name", "Mighty Fighter");
63+
});
64+
```
65+
66+
### Tracing and Performance Monitoring
67+
68+
Utilize the following examples for tracing scenarios:
69+
70+
```javascript
71+
// Create a transaction
72+
const transaction = Sentry.startTransaction({
73+
op: "test",
74+
name: "My First Test Transaction"
75+
});
76+
77+
// Set transaction as the current scope
78+
Sentry.getCurrentHub().configureScope(scope => {
79+
scope.setSpan(transaction);
80+
});
81+
82+
// Create a child span
83+
const span = transaction.startChild({ op: "functionX", description: "Function doing work" });
84+
85+
try {
86+
// Do something...
87+
span.setStatus("ok");
88+
} catch (error) {
89+
span.setStatus("internal_error");
90+
throw error;
91+
} finally {
92+
// Finish the span
93+
span.finish();
94+
// Finish the transaction
95+
transaction.finish();
96+
}
97+
```
98+
99+
### Bun.serve Integration
100+
101+
For Bun server applications:
102+
103+
```javascript
104+
import * as Sentry from "@sentry/bun";
105+
106+
// Initialize Sentry before anything else
107+
Sentry.init({
108+
dsn: "<sentry dsn>",
109+
integrations: [
110+
// Add Bun server integration
111+
Sentry.bunServerIntegration(),
112+
],
113+
tracesSampleRate: 1.0,
114+
});
115+
116+
// Example Bun server
117+
Bun.serve({
118+
port: 3000,
119+
fetch(req) {
120+
const url = new URL(req.url);
121+
122+
if (url.pathname === "/error") {
123+
// This will be automatically captured by Sentry
124+
throw new Error("Example server error");
125+
}
126+
127+
return new Response("Hello World!");
128+
},
129+
});
130+
```

public/platforms/node/llms.txt

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Sentry and Node.js LLM Rules
2+
3+
You are an expert in application architecture and the configuration of observability tools like Sentry. Ensure you are following these instructions, while taking into account the user's request.
4+
5+
Always ensure you are installing Sentry using `npm install @sentry/node@latest` or `yarn add @sentry/node@latest`. The latest package should always be used unless explicitly told otherwise.
6+
7+
## Configuration examples
8+
9+
These examples should be used to configure the different Sentry functionality in Node.js applications. Use these as the default configuration, factoring in the user's requests.
10+
11+
### Sentry Setup (applies to all configurations)
12+
13+
Configure Sentry using the following parameters unless explicitly told otherwise.
14+
15+
```javascript
16+
import * as Sentry from "@sentry/node";
17+
18+
// Initialize Sentry as early as possible
19+
Sentry.init({
20+
dsn: "<sentry dsn>",
21+
22+
// Enable tracing to capture 100% of transactions
23+
// Recommend adjusting this value in production
24+
tracesSampleRate: 1.0,
25+
26+
// Set tracePropagationTargets for which URLs trace propagation should be enabled
27+
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
28+
29+
// Enable HTTP capturing
30+
integrations: [
31+
Sentry.httpIntegration(),
32+
],
33+
});
34+
```
35+
36+
### Error Tracking and Exception Catching
37+
38+
Instrument errors throughout the application using the following approaches:
39+
40+
```javascript
41+
// Explicitly capture an exception
42+
try {
43+
throw new Error("Example error");
44+
} catch (e) {
45+
Sentry.captureException(e);
46+
}
47+
48+
// Capture a custom message
49+
Sentry.captureMessage("Something went wrong", "error");
50+
51+
// Add extra context to the error
52+
Sentry.configureScope((scope) => {
53+
scope.setTag("page_locale", "de-at");
54+
scope.setUser({ id: '123', email: '[email protected]' });
55+
scope.setExtra("character_name", "Mighty Fighter");
56+
});
57+
```
58+
59+
### Tracing and Performance Monitoring
60+
61+
Utilize the following examples for tracing scenarios:
62+
63+
```javascript
64+
// Create a transaction
65+
const transaction = Sentry.startTransaction({
66+
op: "test",
67+
name: "My First Test Transaction"
68+
});
69+
70+
// Set transaction as the current scope
71+
Sentry.getCurrentHub().configureScope(scope => {
72+
scope.setSpan(transaction);
73+
});
74+
75+
// Create a child span
76+
const span = transaction.startChild({ op: "functionX", description: "Function doing work" });
77+
78+
try {
79+
// Do something...
80+
span.setStatus("ok");
81+
} catch (error) {
82+
span.setStatus("internal_error");
83+
throw error;
84+
} finally {
85+
// Finish the span
86+
span.finish();
87+
// Finish the transaction
88+
transaction.finish();
89+
}
90+
```
91+
92+
### Express Framework Integration
93+
94+
For Express.js applications:
95+
96+
```javascript
97+
import express from "express";
98+
import * as Sentry from "@sentry/node";
99+
100+
const app = express();
101+
102+
// Initialize Sentry - this must happen before other app middleware
103+
Sentry.init({
104+
dsn: "<sentry dsn>",
105+
integrations: [
106+
// Enable Express.js monitoring
107+
Sentry.expressIntegration(),
108+
Sentry.httpIntegration(),
109+
],
110+
tracesSampleRate: 1.0,
111+
});
112+
113+
// The request handler must be the first middleware on the app
114+
app.use(Sentry.Handlers.requestHandler());
115+
116+
// All your controllers should go here
117+
app.get("/", function rootHandler(req, res) {
118+
res.end("Hello world!");
119+
});
120+
121+
// The error handler must be registered before any other error middleware and after all controllers
122+
app.use(Sentry.Handlers.errorHandler());
123+
124+
app.listen(3000);
125+
```

0 commit comments

Comments
 (0)