Skip to content

Commit b690f9d

Browse files
Merge branch 'master' into feat/batch-processor-abnormal-terminations
2 parents 7de1fa9 + 9a76837 commit b690f9d

File tree

104 files changed

+1894
-492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1894
-492
lines changed

develop-docs/backend/application-domains/tasks/index.mdx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,63 @@ def deliver_issue_webhook(organization_id: int, group_id: int) -> None:
213213

214214
If an idempotent task exceeds a processing deadline, it will *not* be retried.
215215

216+
## Task Aliasing
217+
218+
Task aliasing allows you to rename tasks or move them to different namespaces while maintaining backwards compatibility with existing task activations in Kafka. This is useful when refactoring task organization or renaming tasks without losing queued tasks. Task aliases inherit the same retry policy, processing deadline, and other configuration from the primary task definition.
219+
220+
### Renaming a Task
221+
222+
When renaming a task, use the `alias` parameter to specify the old task name:
223+
224+
```python
225+
@instrumented_task(
226+
name="sentry.widgets.tasks.do_work_v2", # New task name
227+
namespace=issues_tasks,
228+
alias="sentry.widgets.tasks.do_work", # Old task name
229+
)
230+
def do_work() -> None:
231+
...
232+
```
233+
234+
New activations will be created using `name`. However, both task names will be registered and can process activations. Workers will handle tasks sent to either `do_work_v2` or `do_work` with the same function.
235+
236+
### Moving to a Different Namespace
237+
238+
To move a task from one namespace to another, use the `alias_namespace` parameter:
239+
240+
```python
241+
from sentry.taskworker.namespaces import issues_tasks, integrations_tasks
242+
243+
@instrumented_task(
244+
name="sentry.widgets.tasks.do_work",
245+
namespace=integrations_tasks, # New namespace
246+
alias_namespace=issues_tasks, # Old namespace
247+
)
248+
def do_work() -> None:
249+
...
250+
```
251+
252+
The task will be registered in both `performance_tasks` and `issues_tasks` for the same task name `sentry.widgets.tasks.do_work`, allowing in-flight activations in the old namespace to process.
253+
254+
### Renaming and Moving Together
255+
256+
You can combine both `alias` and `alias_namespace` to rename a task and move it to a different namespace simultaneously:
257+
258+
```python
259+
@instrumented_task(
260+
name="sentry.widgets.tasks.do_work_v2", # New name
261+
namespace=integrations_tasks, # New namespace
262+
alias="sentry.widgets.tasks.do_work", # Old name
263+
alias_namespace=issues_tasks, # Old namespace
264+
)
265+
def do_work() -> None:
266+
...
267+
```
268+
269+
This registers the task as both:
270+
- `integrations_tasks:sentry.widgets.tasks.do_work_v2` (new)
271+
- `issues_tasks:sentry.widgets.tasks.do_work` (old)
272+
216273
## Testing Tasks
217274

218275
Tasks can be tested with a few different approaches. The first is with the

develop-docs/development-infrastructure/backend-development-server.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar_order: 20
55

66
(*see also: [Frontend Development Server](/frontend/development-server/)*)
77

8-
It's possible to run Sentry locally without ever having to build the frontend. It requires to circumvent `sentry devserver`. Instead, you configure:
8+
It's possible to run Sentry locally without ever having to build the frontend. It requires to circumvent the devserver. Instead, you configure:
99

1010
```python
1111
# ~/.sentry/sentry.conf.py

develop-docs/development-infrastructure/environment/index.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ SENTRY_SILO_DEVSERVER=1 SENTRY_SILO_MODE=CONTROL getsentry django shell
183183
SENTRY_SILO_DEVSERVER=1 SENTRY_SILO_MODE=REGION SENTRY_REGION=us getsentry django shell
184184
```
185185

186-
## Troubleshooting
187-
188-
The more up-to-date troubleshooting docs for the _internal_ development environment on MacOS are <Link to="https://www.notion.so/sentry/devenv-troubleshooting-1448b10e4b5d8080ba04f452e33de48d">here</Link>.
189-
190-
You might also be interested in <Link to="/development/continuous-integration/#troubleshooting-ci">Troubleshooting CI</Link>.
191-
192186
---
193187

194188
**Problem:** `DoesNotExist: Subscription matching query does not exist` during getsentry devserver
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Troubleshooting Development Environment Issues
2+
3+
The troubleshooting docs for the _internal_ development environment on MacOS are [here](https://www.notion.so/sentry/devenv-troubleshooting-1448b10e4b5d8080ba04f452e33de48d)

develop-docs/sdk/data-model/event-payloads/stacktrace.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ follow this rule of thumb:
2626
ordered from caller to callee, or oldest to youngest. The last frame is the
2727
one creating the exception.
2828

29+
In cases where the event payload is oversized (for instance, for recursion / stackoverflow errors),
30+
some SDKs truncate the frames to make sure the event gets sent and is not dropped completely.
31+
The recommended way to truncate in this case is take 500 frames on both sides so that Relay can further truncate on both sides as it wishes.
32+
2933
`registers`
3034

3135
: _Optional_. A map of register names and their values. The values should

develop-docs/sdk/expected-features/data-handling.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Fields in the event payload that allow user-specified or dynamic values are rest
121121
- Messages are limited to 8192 characters.
122122
- HTTP data (the body) is limited to 8kB. Always trim HTTP data before attaching it to the event.
123123
- Stack traces are limited to 50 frames. If more are sent, data will be removed from the middle of the stack.
124+
- Input messages in AI integrations recorded in the span attribute `gen_ai.request.messages` are limited to 20kB per span. Messages are trimmed and truncated if they exceed the limit, retaining the most recent messages.
124125

125126
Additionally, size limits apply to all store requests for the total size of the request, event payload, and attachments. Sentry rejects all requests exceeding these limits. Please refer the following resources for the exact size limits:
126127

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
---
2+
title: AWS Lambda Development Environment
3+
description: How to configure AWS Lambda to send data to a development Sentry instance.
4+
sidebar_order: 200
5+
---
6+
7+
This guide will explain how you can setup a development environment to work on the [AWS Lambda Integration](https://docs.sentry.io/product/integrations/cloud-monitoring/aws-lambda/). The setup includes running a local instance of `sentry` and configuring AWS so that both environments work together.
8+
9+
<Alert level="warning" title="IMPORTANT">
10+
11+
**This guide is only if you want to send data from an AWS Lambda function to your local `sentry` instance.**
12+
13+
When working on the Sentry AWS Lambda layer from one of the SDKs, the workflow is that you have your example Lambda function in a dev account on AWS and then deploy your local layer to the dev account and attach it to your example function. How do to this in Python is described in the [contribution guide](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md#contributing-to-sentry-aws-lambda-layer) of the Python SDK.
14+
15+
</Alert>
16+
17+
## Configuration of AWS
18+
19+
To emulate a Sentry integration with a project base on AWS Lambda functions you need:
20+
21+
- One AWS account representing Sentry having an IAM and a S3 Bucket containing a JSON config file.
22+
- One AWS account representing the user that has a example Lambda function.
23+
24+
### Detailed Configuration Steps
25+
26+
For the **“Sentry Account”** in AWS we assume the AWS Account ID is `1111 1111 1111` in this guide. This account can be the shared official dev AWS account of Sentry, or you can create a personal one (credit card required for this)
27+
28+
- Create an **IAM user** in the **“Sentry account”** that can create S3 buckets, and has permission to assume roles. The policy that can be directly attached to the IAM user looks like this:
29+
30+
{/* _TODO: check if we can restrict those permissions more_ */}
31+
32+
```json
33+
{
34+
"Version": "2012-10-17",
35+
"Statement": [
36+
{
37+
"Sid": "VisualEditor0",
38+
"Effect": "Allow",
39+
"Action": "sts:AssumeRole",
40+
"Resource": "*"
41+
}
42+
]
43+
}
44+
```
45+
46+
- Create an **S3 Bucket in “Sentry Account”** that is accessible by the public to host the CloudFormation configuration file. (more on this later). The S3 Bucket Policy should look like this (in this example “sentry-dev-cloudformation” is the name of the S3 bucket):
47+
48+
{/* _TODO: check if we can restrict those permissions more_ */}
49+
50+
```json
51+
{
52+
"Version": "2012-10-17",
53+
"Statement": [
54+
{
55+
"Sid": "Statement1",
56+
"Effect": "Allow",
57+
"Principal": "*",
58+
"Action": "s3:*",
59+
"Resource": [
60+
"arn:aws:s3:::sentry-dev-cloudformation",
61+
"arn:aws:s3:::sentry-dev-cloudformation/dev.json"
62+
]
63+
}
64+
]
65+
}
66+
```
67+
68+
- Place a **CloudFormation configuration file** called `dev.json` in the S3 bucket of the “Sentry account” mentioned above. The `dev.json` file is a pointer to a “Sentry account” user. The file must be readable by the customer.
69+
The dev.json must look like this. You need to replace `arn:aws:iam::111111111111:user/sentry` with the ARN of your user:
70+
71+
{/* *TODO: check if we can restrict those permissions more.* */}
72+
73+
```json
74+
{
75+
"Description": "This stack grants write access to your Lambda functions in order to add Sentry error and performance monitoring. After pressing create, wait for the stack to be created before copying your AWS account number and region into the Sentry installation modal.",
76+
"Resources": {
77+
"SentryRole": {
78+
"Type": "AWS::IAM::Role",
79+
"Properties": {
80+
"AssumeRolePolicyDocument": {
81+
"Version": "2012-10-17",
82+
"Statement": [
83+
{
84+
"Effect": "Allow",
85+
"Principal": {
86+
"AWS": "arn:aws:iam::111111111111:user/sentry"
87+
},
88+
"Action": [
89+
"sts:AssumeRole"
90+
],
91+
"Condition": {
92+
"StringEquals": {
93+
"sts:ExternalId": {
94+
"Ref": "ExternalId"
95+
}
96+
}
97+
}
98+
}
99+
]
100+
},
101+
"Path": "/",
102+
"RoleName": "SentryRole",
103+
"ManagedPolicyArns": [],
104+
"Policies": [
105+
{
106+
"PolicyName": "sentry-policy",
107+
"PolicyDocument": {
108+
"Version": "2012-10-17",
109+
"Statement": [
110+
{
111+
"Effect": "Allow",
112+
"Action": [
113+
"lambda:UpdateFunctionConfiguration",
114+
"lambda:ListFunctions",
115+
"lambda:ListLayerVersions",
116+
"lambda:GetFunction",
117+
"lambda:GetLayerVersion",
118+
"organizations:DescribeAccount"
119+
],
120+
"Resource": "*"
121+
}
122+
]
123+
}
124+
}
125+
]
126+
}
127+
}
128+
},
129+
"Parameters": {
130+
"ExternalId": {
131+
"Description": "External ID for securing the role - Do not change",
132+
"Type": "String"
133+
}
134+
}
135+
}
136+
```
137+
138+
This CloudFormation config file basically gives the user in the “Sentry account” access to assume a role in the “User account” to augment the Lambda functions (add the Sentry Lambda Layer) to instrument them for sending errors/metrics to Sentry
139+
140+
- Create one **AWS** account representing the user and where the Lambda functions of the user live. This account we will call the **User account”**.
141+
The **“Sentry account”** and the **“User account”** can also be the same account.
142+
143+
Ok, so now you have two AWS accounts and you have set up your CloudFormation config in a S3 bucket that is accessible to the world. Great!
144+
145+
## Configuration of Local Sentry Instance
146+
147+
You need just a default installation of `sentry` on your computer. Please install it following the [Development Environment Setup Guide](https://develop.sentry.dev/development-infrastructure/environment/).
148+
149+
Now you have to tell your sentry installation what AWS account to use and where it can find the CloudFormation configuration.
150+
151+
You can do this by adding the following parameter to your `~/.sentry/config.yml` file:
152+
153+
```yaml
154+
aws-lambda.access-key-id: AKIXXXXXXXXXXXXXXXXX
155+
aws-lambda.secret-access-key: IuyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2Xoj
156+
aws-lambda.cloudformation-url: https://sentry-dev-cloudformation.s3.eu-central-1.amazonaws.com/dev.json
157+
aws-lambda.node.layer-version: "37"
158+
aws-lambda.python.layer-version: "142"
159+
```
160+
161+
Explanation:
162+
163+
- `aws-lambda.access-key-id` AWS access key id of the IAM user created in the “Sentry Account”.
164+
- `aws-lambda.secret-access-key`AWS secret access key of the IAM user created in the “Sentry Account”.
165+
- `aws-lambda.cloudformation-url` public accessible URL of the CloudFormation config file that lives in a S3 bucket in the “Sentry Account”.
166+
- `aws-lambda.node.layer-version` the version of the Lambda layer that should be used for Node Lambda functions. This version number can be found here: [https://github.com/getsentry/sentry-release-registry/tree/master/aws-lambda-layers](https://github.com/getsentry/sentry-release-registry/tree/master/aws-lambda-layers) (Hint: every region can have another version of the Layer installed.)
167+
- `aws-lambda.python.layer-version` same as above but for Python based Lambda functions.
168+
169+
## Configuration of Ngrok
170+
171+
With [Ngrok](https://ngrok.com/) you get an URL that points to your local computer. So everyone on the internet can talk to your Sentry installation on your computer.
172+
173+
This is needed so your AWS Lambda function can send its errors/tracing to your local Sentry installation.
174+
175+
Follow the instructions on the [Ngrok documentation](https://develop.sentry.dev/development/ngrok/) page to install ngrok.
176+
177+
Now start Ngrok like the following:
178+
179+
```bash
180+
ngrok http 8000
181+
```
182+
183+
If ngrok starts it outputs the URL that your computer is now available at. Copy the HTTP URL (it should look something like `http://xxxx-xxx-xxx-x-xxx.ngrok.io`).
184+
185+
If you follow the guide in the ngrok page linked above you will get access to the Sentry Ngrok account and you can create a subdomain that is custom and not always changing when you restart ngrok. This is highly recommended.
186+
187+
You now have to tell your sentry installation its new URL by adding the following line to your `~/.sentry/config.yml` :
188+
189+
```yaml
190+
system.url-prefix: "http://xxxx-xxx-xxx-x-xxx.ngrok.io"
191+
```
192+
193+
Make sure to restart all the development environment, to make sure all services know about the new URL. (with `devservices down && devservices up`)
194+
195+
## Start the Local Sentry Server
196+
197+
If you now run your local Sentry with this command, it will have all the information it needs:
198+
199+
```bash
200+
devservices serve
201+
```
202+
203+
You are now ready for serverless integration development.
204+
205+
## Add Sentry to Your Lambda Functions
206+
207+
Log into your local sentry environment at your ngrok URL and follow the [AWS Lambda Guide](https://docs.sentry.io/product/integrations/cloud-monitoring/aws-lambda/) in our documentation to add Sentry instrumentation to your demo AWS Lambda function.

develop-docs/sdk/platform-specifics/serverless-sdks/aws-lambda.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: AWS Lambda
3-
sidebar_order: 10
2+
title: AWS Lambda Primer
3+
sidebar_order: 100
44
---
55

66
Lambda functions can be written in numerous programming languages (JavaScript,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: How to Download Production Sentry Lambda Layer
3+
description: Instructions for downloading the Sentry AWS Lambda layer.
4+
sidebar_order: 300
5+
---
6+
7+
You need to have the [AWS CLI](https://aws.amazon.com/cli/) installed and configured to have access to the production Sentry AWS account.
8+
9+
Then you can get information about the Sentry Lambda layer with this command:
10+
```bash
11+
aws lambda get-layer-version --layer-name arn:aws:lambda:eu-central-1:943013980633:layer:SentryPythonServerlessSDK --version-number 142
12+
```
13+
Make sure you have the region (in the example `eu-central-1`) and the version number (in the example `142`) to the version of the layer you want to download. If you want to download the Javascript layer use `SentryNodeServerlessSDKvX` (replacing `X` with the version of the JS SDK is in the layer) instead of `SentryPythonServerlessSDK`.
14+
15+
Output will be something like this:
16+
17+
```bash
18+
{
19+
"Content": {
20+
"Location": "https://awslambda-eu-cent-1-layers.s3.eu-central-1.amazonaws.com/snapshots/943013980633/SentryPythonServerlessSDK-008d308b-4dc8-46c4-b7f2-48c31e187a85?versionId=xxx&X-Amz-Security-Token=xxx&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20260825T072152Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=xxx&X-Amz-Signature=xxx",
21+
"CodeSha256": "L/xPQraARPazFPwChPLlzETN2emli4UIgabUOu34bZ4=",
22+
"CodeSize": 9883188
23+
},
24+
"LayerArn": "arn:aws:lambda:eu-central-1:943013980633:layer:SentryPythonServerlessSDK",
25+
"LayerVersionArn": "arn:aws:lambda:eu-central-1:943013980633:layer:SentryPythonServerlessSDK:35",
26+
"Description": "",
27+
"CreatedDate": "2026-08-16T11:15:45.768+0000",
28+
"Version": 142,
29+
"CompatibleRuntimes": [
30+
"...",
31+
"python3.13",
32+
"python3.14"
33+
],
34+
"LicenseInfo": "MIT"
35+
}
36+
```
37+
38+
Then pick the `Location` and download the layer as zip file:
39+
40+
```bash
41+
curl -o layer.zip https://awslambda-eu-cent-1-layers.s3.eu-central-1.amazonaws.com/snapshots/943013980633/SentryPythonServerlessSDK-008d308b-4dc8-46c4-b7f2-48c31e187a85?versionId=xxx&X-Amz-Security-Token=xxx&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20260825T072152Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=xxx&X-Amz-Signature=xxx
42+
```
43+
44+
Now your layer is in `layer.zip`. Enjoy!

develop-docs/sdk/telemetry/logs.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Sentry.logger.warn("User %s performed action %s", [userId, actionName], {
188188
});
189189
```
190190

191-
Aside from accepting attributes, these methods can be overloaded to accept severity number or other parameters if required for the language or platform.
191+
Aside from accepting attributes, these methods can be overloaded to accept severity number or other parameters if required for the language or platform. The Hub/Scope MUST offer the same methods as the static API `Sentry.logger.X`, which is useful for power users who want to use multiple Hubs/Scopes. The Client SHOULD only offer one generic method that accepts the log object and the Scope, such as `captureLog(log, scope)`.
192192

193193
Beyond the specified methods, SDKs are free to add any extra helpers as they feel is necessary. For example, they could choose to add specialized decorators or helpers for string template creation.
194194

@@ -255,6 +255,8 @@ In general log processing should follow this order:
255255

256256
1. Capture log via [Public APIs](#logger-module) (e.g. `Sentry.logger.info`) or via [SDK integrations](#sdk-integrations).
257257
1. Check if logging is enabled as per `enableLogs`/`enable_logs` configuration - if not, skip the rest of the steps.
258+
1. Pass the log to Hub/Scope, which MUST offer the same methods as the static API `Sentry.logger.X`. This is useful for power users who want to use multiple Hubs/Scopes.
259+
1. Pass the log to the Client, via a generic method that accepts the log object and the `scope`, such as `captureLog(log, scope)`.
258260
1. Process captured log (attach attributes as per [default attributes](#default-attributes)).
259261
1. Run `beforeSendLog`/`before_send_log` to filter or modify the log.
260262
1. Add log to buffer/batch processor as detailed in [buffering](#buffering).

0 commit comments

Comments
 (0)