Skip to content

Commit fbd5be5

Browse files
committed
Adding ruby and node, updating main llms.txt
1 parent 7621e7f commit fbd5be5

File tree

3 files changed

+270
-0
lines changed

3 files changed

+270
-0
lines changed

public/llms.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Sentry llms.txt
2+
3+
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.
4+
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+
[Node.js](/platforms/node/llms.txt)
10+
[Ruby](/platforms/ruby/llms.txt)
11+
[Bun](/platforms/bun/llms.txt)

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+
```

public/platforms/ruby/llms.txt

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Sentry and Ruby 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 `gem 'sentry-ruby', '~> 5.x'`. 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 Ruby 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+
```ruby
16+
require 'sentry-ruby'
17+
18+
Sentry.init do |config|
19+
config.dsn = '<sentry dsn>'
20+
21+
# Get breadcrumbs from logs
22+
config.breadcrumbs_logger = [:sentry_logger, :http_logger]
23+
24+
# Add data like request headers and IP for users
25+
config.send_default_pii = true
26+
27+
# Enable tracing - adjust in production
28+
config.traces_sample_rate = 1.0
29+
30+
# Enable profiling - relative to traces_sample_rate
31+
config.profiles_sample_rate = 1.0
32+
end
33+
```
34+
35+
### Rails Setup
36+
37+
For Rails applications, create a file in `config/initializers/sentry.rb` with the following:
38+
39+
```ruby
40+
Sentry.init do |config|
41+
config.dsn = '<sentry dsn>'
42+
43+
# Get breadcrumbs from logs
44+
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
45+
46+
# Add data like request headers and IP for users
47+
config.send_default_pii = true
48+
49+
# Enable tracing - adjust in production
50+
config.traces_sample_rate = 1.0
51+
52+
# Enable profiling - relative to traces_sample_rate
53+
config.profiles_sample_rate = 1.0
54+
55+
# To set a uniform sample rate
56+
# config.sample_rate = 0.5
57+
end
58+
```
59+
60+
### Rack Setup
61+
62+
For Rack applications, set up Sentry in your `config.ru` or rackup file:
63+
64+
```ruby
65+
require 'sentry-ruby'
66+
67+
Sentry.init do |config|
68+
config.dsn = '<sentry dsn>'
69+
config.breadcrumbs_logger = [:sentry_logger, :http_logger]
70+
config.send_default_pii = true
71+
config.traces_sample_rate = 1.0
72+
config.profiles_sample_rate = 1.0
73+
end
74+
75+
use Sentry::Rack::CaptureExceptions
76+
```
77+
78+
### Error Tracking and Exception Catching
79+
80+
Instrument errors throughout the application using the following approaches:
81+
82+
```ruby
83+
# Explicitly capture an exception
84+
begin
85+
1 / 0
86+
rescue ZeroDivisionError => exception
87+
Sentry.capture_exception(exception)
88+
end
89+
90+
# Capture a custom message
91+
Sentry.capture_message('Something went wrong')
92+
93+
# Add context to events
94+
Sentry.configure_scope do |scope|
95+
scope.set_user(id: 1, email: "[email protected]")
96+
scope.set_tag(:page_locale, "de-at")
97+
scope.set_extra(:character_name, "Mighty Fighter")
98+
end
99+
```
100+
101+
### Tracing and Performance Monitoring
102+
103+
Utilize the following examples for tracing scenarios:
104+
105+
```ruby
106+
# Create a transaction
107+
Sentry.start_transaction(name: "task_name", op: "task") do |transaction|
108+
# Create a child span
109+
Sentry.start_span(op: "subtask", description: "Subtask description") do |span|
110+
begin
111+
# Your code here
112+
span.set_data(:key, "value")
113+
rescue => e
114+
# Record failure information
115+
span.set_status(:internal_error)
116+
raise e
117+
end
118+
end
119+
end
120+
```
121+
122+
### Background Job Integration
123+
124+
For Sidekiq, use the following setup:
125+
126+
```ruby
127+
require 'sentry-ruby'
128+
require 'sentry-sidekiq'
129+
130+
Sentry.init do |config|
131+
config.dsn = '<sentry dsn>'
132+
config.traces_sample_rate = 1.0
133+
end
134+
```

0 commit comments

Comments
 (0)