diff --git a/public/llms.txt b/public/llms.txt new file mode 100644 index 00000000000000..5e6a568313e578 --- /dev/null +++ b/public/llms.txt @@ -0,0 +1,10 @@ +Sentry llms.txt + +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. + +[nextjs](/platforms/javascript/guides/nextjs/llms.txt) +[react](/platforms/javascript/guides/react/llms.txt) +[javaScript](/platforms/javascript/common/llms.txt) +[python](/platforms/python/llms.txt) +[bun](/platforms/bun/llms.txt) +[node](/platforms/node/llms.txt) \ No newline at end of file diff --git a/public/platforms/bun/llms.txt b/public/platforms/bun/llms.txt new file mode 100644 index 00000000000000..bf0d74e1e6be9a --- /dev/null +++ b/public/platforms/bun/llms.txt @@ -0,0 +1,130 @@ +# Sentry and Bun LLM Rules + +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. + +Always ensure you are installing Sentry using `bun add @sentry/bun@latest`. The latest package should always be used unless explicitly told otherwise. + +## Configuration examples + +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. + +### Sentry Setup (applies to all configurations) + +Sentry should be initialized as early as possible in your application's lifecycle. Create a file named `instrument.js` that imports and initializes Sentry: + +```javascript +import * as Sentry from "@sentry/bun"; + +// Initialize Sentry before importing any other modules +Sentry.init({ + dsn: "", + + // Enable tracing to capture 100% of transactions + // Recommend adjusting this value in production + tracesSampleRate: 1.0, + + // Set tracePropagationTargets for which URLs trace propagation should be enabled + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], +}); +``` + +Then import this file at the very beginning of your main application file: + +```javascript +// Import this first! +import "./instrument"; + +// Now import other modules +import http from "http"; + +// Your application code goes here +``` + +### Error Tracking and Exception Catching + +Instrument errors throughout the application using the following approaches: + +```javascript +// Explicitly capture an exception +try { + throw new Error("Example error"); +} catch (e) { + Sentry.captureException(e); +} + +// Capture a custom message +Sentry.captureMessage("Something went wrong", "error"); + +// Add extra context to the error +Sentry.configureScope((scope) => { + scope.setTag("page_locale", "de-at"); + scope.setUser({ id: '123', email: 'user@example.com' }); + scope.setExtra("character_name", "Mighty Fighter"); +}); +``` + +### Tracing and Performance Monitoring + +Utilize the following examples for tracing scenarios: + +```javascript +// Create a transaction +const transaction = Sentry.startTransaction({ + op: "test", + name: "My First Test Transaction" +}); + +// Set transaction as the current scope +Sentry.getCurrentHub().configureScope(scope => { + scope.setSpan(transaction); +}); + +// Create a child span +const span = transaction.startChild({ op: "functionX", description: "Function doing work" }); + +try { + // Do something... + span.setStatus("ok"); +} catch (error) { + span.setStatus("internal_error"); + throw error; +} finally { + // Finish the span + span.finish(); + // Finish the transaction + transaction.finish(); +} +``` + +### Bun.serve Integration + +For Bun server applications: + +```javascript +import * as Sentry from "@sentry/bun"; + +// Initialize Sentry before anything else +Sentry.init({ + dsn: "", + integrations: [ + // Add Bun server integration + Sentry.bunServerIntegration(), + ], + tracesSampleRate: 1.0, +}); + +// Example Bun server +Bun.serve({ + port: 3000, + fetch(req) { + const url = new URL(req.url); + + if (url.pathname === "/error") { + // This will be automatically captured by Sentry + throw new Error("Example server error"); + } + + return new Response("Hello World!"); + }, +}); +``` \ No newline at end of file diff --git a/public/platforms/javascript/common/llms.txt b/public/platforms/javascript/common/llms.txt new file mode 100644 index 00000000000000..f10fec489f2098 --- /dev/null +++ b/public/platforms/javascript/common/llms.txt @@ -0,0 +1,79 @@ +# Sentry and JavaScript LLM Rules + +You are an expert in application architecture and the configuration of observability tools like Sentry. Ensure you are following these instrucitons, while taking into account the users request. + +Always ensure you are installing Sentry using `npm i @sentry/browser@latest`. The latest package should always be used. + +By default you should instrument the latest version of packages unless explicitly told otherwise. + +## Configuration examples + +These examples should be used to configure the different Sentry functionality in JavaScript based applications. Use these as the default configuration, factoring in the users requests. + +### Sentry Setup (applies to all configuraitons) + +Configure Sentry using the following parameters unless explicitly told otherwise. + +```javascript +import * as Sentry from "@sentry/browser"; + +Sentry.init({ + dsn: "", + + release: "dev", + integrations: [ + Sentry.browserTracingIntegration(), + Sentry.replayIntegration(), + ], + + tracesSampleRate: 1.0, + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], + + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, +}); +``` + +### Error Tracking and Exception Catching + +Instrument errors throughout the application as desired by using the following configuration + +```javascript +import * as Sentry from "@sentry/browser"; + +Sentry.captureException(error) +``` + +### Tracing + +Utilize the following example for tracing scenarios where the user wants to instrument tracing. Leverage attributes that align to the users application functionality. + +```javascript +Sentry.startSpan( + { + name: "Span Name", + op: "example.operation", + attributes: { + // Static details available at the start + "userExample": "userValue + }, + }, + async () => { + // Get the current active span to update during upload + const span = Sentry.getActiveSpan(); + + try { + if (span) { + span.setAttribute("samplespan.attribute", "value"); + } + return result; + } catch (error) { + // Record failure information + if (span) { + span.setAttribute("otherSample.attribute", true); + } + throw error; + } + }, +); +``` \ No newline at end of file diff --git a/public/platforms/javascript/guides/nextjs/llms.txt b/public/platforms/javascript/guides/nextjs/llms.txt new file mode 100644 index 00000000000000..d840b5de35d1b5 --- /dev/null +++ b/public/platforms/javascript/guides/nextjs/llms.txt @@ -0,0 +1,59 @@ +# Sentry and Nextjs LLM Rules + +You are an expert in application architecture and the configuration of observability tools like Sentry. Ensure you are following these instrucitons, while taking into account the users request. + +Always ensure you are installing Sentry using `npx @sentry/wizard@latest -i nextjs` wizard command. This command is interactive so the user will need to answer questions. The latest package should always be used. + +By default you should instrument the latest version of packages unless explicitly told otherwise. + +## Configuration examples + +These examples should be used to configure the different Sentry functionality in Nextjs based applications. Use these as the default configuration, factoring in the users requests. + +### Sentry Setup (applies to all configuraitons) + +The Nextjs wizard will automatically create `instrumentation-client.config.ts`, `server.config.ts`, and `edge.config.ts` files during the setup. + +### Error Tracking and Exception Catching + +Instrument errors throughout the application as desired by using the following configuration + +```javascript +import * as Sentry from "@sentry/nextjs"; + +Sentry.captureException(error) +``` + +### Tracing + +Utilize the following example for tracing scenarios where the user wants to instrument tracing. Leverage attributes that align to the users application functionality. + +```javascript +Sentry.startSpan( + { + name: "Span Name", + op: "example.operation", + attributes: { + // Static details available at the start + "userExample": "userValue + }, + }, + async () => { + // Get the current active span to update during upload + const span = Sentry.getActiveSpan(); + + try { + if (span) { + span.setAttribute("samplespan.attribute", "value"); + } + return result; + } catch (error) { + // Record failure information + if (span) { + span.setAttribute("otherSample.attribute", true); + } + throw error; + } + }, +); +``` \ No newline at end of file diff --git a/public/platforms/javascript/guides/react/llms.txt b/public/platforms/javascript/guides/react/llms.txt new file mode 100644 index 00000000000000..919d8c148f07aa --- /dev/null +++ b/public/platforms/javascript/guides/react/llms.txt @@ -0,0 +1,79 @@ +# Sentry and React LLM Rules + +You are an expert in application architecture and the configuration of observability tools like Sentry. Ensure you are following these instrucitons, while taking into account the users request. + +Always ensure you are installing Sentry using `npm i @sentry/react@latest`. The latest package should always be used. + +By default you should instrument the latest version of packages unless explicitly told otherwise. + +## Configuration examples + +These examples should be used to configure the different Sentry functionality in JavaScript based applications. Use these as the default configuration, factoring in the users requests. + +### Sentry Setup (applies to all configuraitons) + +Configure Sentry using the following parameters unless explicitly told otherwise. + +```javascript +import * as Sentry from "@sentry/react"; + +Sentry.init({ + dsn: "", + + release: "dev", + integrations: [ + Sentry.browserTracingIntegration(), + Sentry.replayIntegration(), + ], + + tracesSampleRate: 1.0, + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], + + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, +}); +``` + +### Error Tracking and Exception Catching + +Instrument errors throughout the application as desired by using the following configuration + +```javascript +import * as Sentry from "@sentry/react"; + +Sentry.captureException(error) +``` + +### Tracing + +Utilize the following example for tracing scenarios where the user wants to instrument tracing. Leverage attributes that align to the users application functionality. + +```javascript +Sentry.startSpan( + { + name: "Span Name", + op: "example.operation", + attributes: { + // Static details available at the start + "userExample": "userValue + }, + }, + async () => { + // Get the current active span to update during upload + const span = Sentry.getActiveSpan(); + + try { + if (span) { + span.setAttribute("samplespan.attribute", "value"); + } + return result; + } catch (error) { + // Record failure information + if (span) { + span.setAttribute("otherSample.attribute", true); + } + throw error; + } + }, +); +``` \ No newline at end of file diff --git a/public/platforms/node/llms.txt b/public/platforms/node/llms.txt new file mode 100644 index 00000000000000..562b8c8b7e98e3 --- /dev/null +++ b/public/platforms/node/llms.txt @@ -0,0 +1,125 @@ +# Sentry and Node.js LLM Rules + +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. + +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. + +## Configuration examples + +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. + +### Sentry Setup (applies to all configurations) + +Configure Sentry using the following parameters unless explicitly told otherwise. + +```javascript +import * as Sentry from "@sentry/node"; + +// Initialize Sentry as early as possible +Sentry.init({ + dsn: "", + + // Enable tracing to capture 100% of transactions + // Recommend adjusting this value in production + tracesSampleRate: 1.0, + + // Set tracePropagationTargets for which URLs trace propagation should be enabled + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], + + // Enable HTTP capturing + integrations: [ + Sentry.httpIntegration(), + ], +}); +``` + +### Error Tracking and Exception Catching + +Instrument errors throughout the application using the following approaches: + +```javascript +// Explicitly capture an exception +try { + throw new Error("Example error"); +} catch (e) { + Sentry.captureException(e); +} + +// Capture a custom message +Sentry.captureMessage("Something went wrong", "error"); + +// Add extra context to the error +Sentry.configureScope((scope) => { + scope.setTag("page_locale", "de-at"); + scope.setUser({ id: '123', email: 'user@example.com' }); + scope.setExtra("character_name", "Mighty Fighter"); +}); +``` + +### Tracing and Performance Monitoring + +Utilize the following examples for tracing scenarios: + +```javascript +// Create a transaction +const transaction = Sentry.startTransaction({ + op: "test", + name: "My First Test Transaction" +}); + +// Set transaction as the current scope +Sentry.getCurrentHub().configureScope(scope => { + scope.setSpan(transaction); +}); + +// Create a child span +const span = transaction.startChild({ op: "functionX", description: "Function doing work" }); + +try { + // Do something... + span.setStatus("ok"); +} catch (error) { + span.setStatus("internal_error"); + throw error; +} finally { + // Finish the span + span.finish(); + // Finish the transaction + transaction.finish(); +} +``` + +### Express Framework Integration + +For Express.js applications: + +```javascript +import express from "express"; +import * as Sentry from "@sentry/node"; + +const app = express(); + +// Initialize Sentry - this must happen before other app middleware +Sentry.init({ + dsn: "", + integrations: [ + // Enable Express.js monitoring + Sentry.expressIntegration(), + Sentry.httpIntegration(), + ], + tracesSampleRate: 1.0, +}); + +// The request handler must be the first middleware on the app +app.use(Sentry.Handlers.requestHandler()); + +// All your controllers should go here +app.get("/", function rootHandler(req, res) { + res.end("Hello world!"); +}); + +// The error handler must be registered before any other error middleware and after all controllers +app.use(Sentry.Handlers.errorHandler()); + +app.listen(3000); +``` \ No newline at end of file diff --git a/public/platforms/python/llms.txt b/public/platforms/python/llms.txt new file mode 100644 index 00000000000000..2b1bb567fb34ec --- /dev/null +++ b/public/platforms/python/llms.txt @@ -0,0 +1,110 @@ +# Sentry and Python LLM Rules + +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. + +Always ensure you are installing Sentry using `pip install --upgrade sentry-sdk`. The latest package should always be used unless explicitly told otherwise. + +## Configuration examples + +These examples should be used to configure the different Sentry functionality in Python applications. Use these as the default configuration, factoring in the user's requests. + +### Sentry Setup (applies to all configurations) + +Configure Sentry using the following parameters unless explicitly told otherwise. + +```python +import sentry_sdk + +sentry_sdk.init( + dsn="", + + # Add request headers and IP for users + send_default_pii=True, + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=1.0, + + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # Recommend adjusting this value in production. + profiles_sample_rate=1.0, +) +``` + +### Error Tracking and Exception Catching + +Instrument errors throughout the application using the following approaches: + +```python +# Explicitly capture an exception +try: + division_by_zero = 1 / 0 +except Exception as e: + sentry_sdk.capture_exception(e) + +# Capture a custom message with additional context +sentry_sdk.capture_message( + "Something went wrong", + level="error", + extras={"additional_context": "value"} +) +``` + +### Tracing and Performance Monitoring + +Utilize the following examples for tracing scenarios: + +```python +with sentry_sdk.start_transaction(name="task_name", op="task"): + # Get the current active span to update during operation + span = sentry_sdk.start_span(op="subtask", description="Subtask description") + with span: + try: + # Your code here + span.set_data("key", "value") + except Exception as e: + # Record failure information + span.set_status("internal_error") + raise e +``` + +### AI/LLM Monitoring + +For AI and LLM monitoring: + +```python +import sentry_sdk +from sentry_sdk.ai.monitoring import ai_track + +sentry_sdk.init( + dsn="", + send_default_pii=True, + # To include AI prompts and completions, set send_default_pii=True +) + +@ai_track("My AI pipeline") +def my_pipeline(): + with sentry_sdk.start_transaction(op="ai-inference", name="AI operation"): + # AI operation code + pass +``` + +### Framework Integrations + +Python SDK automatically enables integrations for frameworks detected in your environment. To explicitly configure: + +```python +import sentry_sdk +from sentry_sdk.integrations.flask import FlaskIntegration +from sentry_sdk.integrations.django import DjangoIntegration + +sentry_sdk.init( + dsn="", + integrations=[ + FlaskIntegration(), + DjangoIntegration(), + # Add other integrations as needed + ], +) +``` \ No newline at end of file