Skip to content

Commit 596e209

Browse files
author
Shannon Anahata
committed
Merge master to get AI Code Review changes from PR #14991
2 parents 7e9bd4d + e52aeca commit 596e209

File tree

73 files changed

+1423
-440
lines changed

Some content is hidden

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

73 files changed

+1423
-440
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,17 @@ Just like running `sentry` (see above), you can start the `devservices` using th
102102
devservices up
103103
```
104104

105-
You will also need to enable workers which you can do so by running the following command:
105+
To run tasks, you will also need to start taskbroker:
106106

107107
```shell
108-
devservices up taskbroker
108+
# start just taskbroker
109+
devservices up --mode=taskbroker
110+
111+
# start taskbroker and a backgrond worker
112+
devservices up --mode=taskworker
109113
```
110114

111-
or use a --mode that includes workers. If you use the --mode flag of devservices, any modes that started celery workers will now start taskbroker and a taskworker.
115+
If you use the `--mode` flag of devservices, any modes that started celery workers will now start taskbroker and a taskworker.
112116

113117
After that, you can start the development server inside the `getsentry` folder:
114118

develop-docs/development-infrastructure/ngrok.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ In two separate terminal windows, start the devserver for the control and region
102102

103103
First, start the taskbroker:
104104
```shell
105-
devservices up taskbroker
105+
devservices up --mode=taskbroker
106106
```
107107

108108
```shell

develop-docs/ingestion/relay/relay-best-practices.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ Make sure changes to the event protocol and APIs are forward-compatible. Relay s
1616
or truncate data it does not understand. It is a supported use-case to have customers running
1717
outdated Relays but up-to-date SDKs.
1818

19+
For example, `enum`s in the event protocol (or any other data type received from the SDK) need to have a catchall variant
20+
such that customer relays running an older version can still forward the data:
21+
22+
```rust
23+
enum EventColor {
24+
Red,
25+
Green,
26+
Blue,
27+
/// Unknown color, for forward compatibility.
28+
Unknown(String),
29+
}
30+
```
1931

2032
## Feature Gate new Functionality
2133

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

Lines changed: 120 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -51,89 +51,156 @@ created this exception.
5151
`stacktrace`
5252

5353
: An optional stack trace object corresponding to the [Stack Trace Interface](/sdk/data-model/event-payloads/stacktrace/).
54-
5554
## Exception Mechanism
5655

57-
The exception mechanism is an optional field residing in the _Exception
58-
Interface_. It carries additional information about the way the exception was
59-
created on the target system. This includes general exception values obtained
60-
from the operating system or runtime APIs, as well as mechanism-specific values.
56+
The exception mechanism is an optional field residing in the _Exception Interface_.
57+
It carries additional information about the way the exception was created and captured ("capturing mechanism") on the target system.
58+
This includes general exception values obtained from the operating system or runtime APIs, as well as capturing mechanism-specific values.
6159

6260
### Attributes
6361

64-
`type`
62+
#### `type`
63+
64+
Required (`string`)
65+
66+
The identifier of the capturing mechanism that captured the exception.
67+
The chosen mechanism `type` MUST help users as well as Sentry employees determine the responsible mechanism for capturing the exception.
68+
This is either instrumentation within our SDKs or users manually capturing exceptions (for example via `captureException`).
69+
70+
The `type` MUST be _reasonably unique_ to make it possible to identify the integration or SDK API that performed the capture.
71+
There's no strict uniqueness requirement as in certain situations, multiple paths exist within one instrumentation, in which case it is fine to use a common mechanism `type`.
72+
73+
For user-invoked exception captures (e.g. via `captureException`), the `type` MUST be set to `'generic'`.
74+
75+
For SDK-invoked exception captures, the mechanism `type` value MUST NOT be set to `'generic'` and SHOULD follow the [Trace Origin](/sdk/performance/trace-origin/) naming scheme whenever applicable.
76+
For example, if a span is wrapping the exception capture logic, `type` should be equal to this span's `sentry.origin` attribute.
77+
If no (specific) span is present, the `type` SHOULD be set to an adequate value, following the Trace Origin naming scheme as closely as possible.
78+
79+
<Expandable title="Examples">
6580

66-
: Required unique identifier of this mechanism determining rendering and processing of the mechanism data.
81+
Exception capture within a span:
6782

68-
`description`
83+
```js
84+
startSpan(
85+
{
86+
name: 'Middleware',
87+
attributes: { 'sentry.origin': 'auto.http.express.middleware' },
88+
},
89+
() => {
90+
captureException(error, {
91+
mechanism: { type: 'auto.http.express.middleware', handled: false }
92+
});
93+
},
94+
);
95+
```
96+
97+
Exception capture outside of a span:
98+
99+
```js
100+
captureException(error, {
101+
mechanism: { type: 'auto.browser.global_handlers.onerror', handled: false }
102+
});
103+
```
104+
105+
Use `'generic'` for user-invoked exception captures (i.e. default value):
106+
107+
```js
108+
function captureException(error, context) {
109+
const mechanism = {
110+
type: 'generic',
111+
handled: true,
112+
...context?.mechanism,
113+
}
114+
// ...
115+
}
116+
```
69117
70-
: Optional human-readable description of the error mechanism and a possible hint on how to solve this error.
71118
72-
`help_link`
119+
</Expandable>
73120
74-
: Optional fully qualified URL to an online help resource, possibly interpolated with error parameters.
121+
<Expandable title="Why Trace Origin?">
75122
76-
`handled`
123+
Historically, there was no requirement for the `type` attribute naming scheme.
124+
Consequently, different SDKs took diffferent approaches as to how they set the `type` attribute.
125+
In some cases, the `type` attribute was/is not set at all.
126+
Chosing [Trace Origin](/sdk/performance/trace-origin/) as the naming scheme for the `type` attribute means that we're using an already established and accepted naming scheme.
127+
The scheme works well enough for the exception mechanism `type` attribute.
128+
Slight deviations to accomodate for the applicability to exceptions are allowed and to be expected.
129+
SDK maintainers are free to migrate to the new naming scheme for existing capturing mechanisms or use it when adding new mechanisms.
77130
78-
: Optional flag indicating whether the user has handled the exception (for example, via `try ... catch`).
131+
</Expandable>
79132
80-
`synthetic`
133+
#### `handled`
81134
82-
: An optional flag indicating that this error is synthetic. Synthetic errors are errors that
83-
carry little meaning by themselves. This may be because they are created at a central
84-
place (like a crash handler), and are all called the same: `Error`, `Segfault` etc.
85-
When the flag is set, Sentry will then try to use other information (top in-app frame
86-
function) rather than the exception type and value in the UI for the primary event display.
87-
Furthermore, if this flag is set, Sentry will ignore the exception `type` when grouping the
88-
exception into issues.
89-
: This flag should be set for all "segfaults" for instance as every single error group would
90-
look very similar otherwise. Also, errors the SDK creates to add a stack trace to events
91-
that don't have one themselves should be marked as `synthetic` (This happens, for example,
92-
when users set `attachStackTrace: true` and capture a string message via `captureException`
93-
or `captureMessage`.)
135+
Optional (`boolean`)
94136
95-
`exception_id`
137+
Flag indicating whether the user has handled the exception (for example, via `try ... catch`).
96138
97-
: An optional numeric value providing an ID for the exception relative
98-
to this specific event. The SDK should assign simple incrementing integers
99-
to each exception in the tree, starting with 0 for the root of the tree.
100-
In other words, when flattened into the list provided in the exception
101-
values on the event, the last exception in the list should have ID 0,
102-
the previous one should have ID 1, the next previous should have ID 2, etc.
139+
#### `description`
103140
104-
`parent_id`
141+
Optional (`string`)
105142
106-
: An optional numeric value pointing at the exception_id that is the
107-
parent of this exception. The SDK should assign this to all exceptions except
108-
the root exception (the last to be listed in the exception values).
143+
Human-readable description of the error mechanism and a possible hint on how to solve this error.
109144
110-
`is_exception_group`
145+
#### `help_link`
111146
112-
: An optional flag indicating that this exception is part of an exception group type specific to the platform or language.
147+
Optional (`string`)
113148
114-
`source`
149+
Fully qualified URL to an online help resource, possibly interpolated with error parameters.
115150
116-
: An optional string value describing the source of the exception. The SDK should populate this with the name of the property or attribute of the parent exception that this exception was acquired from. In the case of an array, it should include the zero-based array index as well.
151+
#### `synthetic`
152+
153+
Optional (`boolean`)
154+
155+
Flag indicating that this error is synthetic.
156+
Synthetic errors are errors that carry little meaning by themselves.
157+
This may be because they are all created at a central place (like a crash handler), and share the same title: `Error`, `Segfault` etc.
158+
When the flag is set, Sentry will then try to use other information (top in-app frame function) rather than the exception type and value in the UI for the primary event display.
159+
Furthermore, if this flag is set, Sentry will ignore the exception `type` when grouping the exception into issues.
160+
This flag SHOULD be set for all "segfaults" for instance as every single error group would look very similar otherwise.
161+
Also, errors the SDK creates to add a stack trace to events that don't have one themselves SHOULD be marked as `synthetic` (This happens, for example, when users set `attachStackTrace: true` and capture a string message via `captureException` or `captureMessage`.)
162+
163+
#### `exception_id`
164+
165+
Optional (`number`)
166+
167+
An optional numeric value providing an ID for the exception relative to this specific event.
168+
The SDK SHOULD assign simple incrementing integers to each exception in the tree, starting with 0 for the root of the tree.
169+
In other words, when flattened into the list provided in the exception values on the event, the last exception in the list SHOULD have ID 0,
170+
the previous one SHOULD have ID 1, the next previous SHOULD have ID 2, etc.
171+
172+
#### `parent_id`
173+
174+
Optional (`number`)
175+
176+
An optional numeric value pointing at the exception_id that is the parent of this exception.
177+
The SDK SHOULD assign this to all exceptions except the root exception (the last to be listed in the exception values).
178+
179+
#### `is_exception_group`
180+
181+
Optional (`boolean`)
182+
183+
Flag indicating that this exception is part of an exception group type specific to the platform or language.
184+
185+
#### `source`
186+
187+
Optional (`string`)
188+
189+
An optional string value describing the source of the exception.
190+
The SDK SHOULD populate this with the name of the property or attribute of the parent exception that this exception was acquired from.
191+
In the case of an array, it SHOULD include the zero-based array index as well.
117192
118193
- Python Examples: `"__context__"`, `"__cause__"`, `"exceptions[0]"`, `"exceptions[1]"`
119194
- .NET Examples: `"InnerException"`, `"InnerExceptions[0]"`, `"InnerExceptions[1]"`
120195
- JavaScript Examples: `"cause"`, `"errors[0]"`, `"errors[1]"`
121196
122-
`meta`
123-
124-
: Optional information from the operating system or runtime on the exception
125-
mechanism (see [meta information](#meta-information)).
197+
#### `meta`
126198
127-
`data`
199+
Optional information from the operating system or runtime on the exception mechanism (see [meta information](#meta-information)).
128200
129-
: Arbitrary extra data that might help the user understand the error thrown by
130-
this mechanism.
201+
#### `data`
131202
132-
<Alert title="Note" level="warning">
133-
The <code>type</code> attribute is required to send any exception mechanism attribute, even
134-
if the SDK cannot determine the specific mechanism. In this case, set the <code>type</code>
135-
to <code>generic</code>. See below for an example.
136-
</Alert>
203+
Arbitrary extra data that might help the user understand the error thrown by this mechanism.
137204
138205
### Meta information
139206

develop-docs/sdk/expected-features/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Whenever possible, avoid adding the attachment altogether if taking the screensh
233233

234234
## Before-Send Hook
235235

236-
Hook called with the event (and on some platforms the hint) that allows the user to decide whether an event should be sent or not. This can also be used to further modify the event. This only works for `error` events. For `transactions` it is recommended to have `beforeSendTransaction` implemented in SDKs. To understand when you should call this in your SDK, please refer to the [error filter ordering of sessions](/sdk/telemetry/sessions/#filter-order).
236+
Hook called with the event (and on some platforms the hint) that allows the user to decide whether an event should be sent or not. This can also be used to further modify the event. This only works for `error` events. Other event types like `transactions` and `check-ins` **should not** go through `beforeSend`. For `transactions` it is recommended to have `beforeSendTransaction` implemented in SDKs. For `check-ins` you can optionally implement `beforeSendCheckIn`. To understand when you should call this in your SDK, please refer to the [error filter ordering of sessions](/sdk/telemetry/sessions/#filter-order).
237237

238238
## Before-Breadcrumb Hook
239239

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ sidebar_order: 10
55

66
Lambda functions can be written in numerous programming languages (JavaScript,
77
Python, Ruby, Java, Go, ...). Sentry is currently supporting automatic
8-
instrumentation of Lambda functions written in JavaScript and Python.
8+
instrumentation of Lambda functions written in [JavaScript](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/)
9+
and [Python](https://docs.sentry.io/platforms/python/integrations/aws-lambda/).
910

10-
See the [Sentry Documentation](https://docs.sentry.io/product/integrations/cloud-monitoring/) on how to set up serverless instrumentation.
11+
See the [Sentry Documentation](https://docs.sentry.io/product/integrations/cloud-monitoring/)
12+
on how to set up serverless instrumentation.
1113

1214
## A short primer into AWS Lambda functions, and layers.
1315

@@ -79,3 +81,7 @@ this can be found [here](https://github.com/getsentry/sentry-javascript/blob/mas
7981

8082
To deploy a new version of the Lambda layer to AWS, you need to trigger a new
8183
release of the JavaScript SDK.
84+
85+
### Development Environment
86+
87+
When working on the Sentry AWS Lambda layer, the workflow is that you have your example Lambda function in a dev account on AWS and then deploy your local layer and attach it to your example function. How to do 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.

develop-docs/sdk/telemetry/check-ins.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,7 @@ monitors frontend APIs.
159159
`unit`
160160

161161
: **String, required**. The interval unit. Should be one of `year`, `month`, `week`, `day`, `hour`, `minute`.
162+
163+
## Interaction with `beforeSend`
164+
165+
Check-in events in the SDK should **not** go through `beforeSend`. SDKs can optionally implement a dedicated `beforeSendCheckIn` hook that only applies to check-in events.

docs/cli/logs.mdx

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: "Logs"
3+
sidebar_order: 5
4+
description: "Learn how to view and stream logs using the Sentry CLI."
5+
---
6+
7+
The `sentry-cli` tool can be used to view and stream logs from your Sentry projects. This allows you to monitor your application logs directly from the command line.
8+
9+
## Requirements
10+
11+
To use the logs command, you need to:
12+
13+
- [Install](/cli/installation) the Sentry CLI
14+
- [Authenticate](/cli/configuration) with Sentry using an auth token
15+
- Have logs enabled for your project
16+
17+
## Configuration
18+
19+
The logs command uses your Sentry auth token for authentication. You can configure this using:
20+
21+
```bash
22+
sentry-cli login
23+
```
24+
25+
Or by setting the `SENTRY_AUTH_TOKEN` environment variable:
26+
27+
```bash
28+
export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
29+
```
30+
31+
Learn more about the CLI's [configuration file](/cli/configuration#configuration-file).
32+
33+
## Basic Usage
34+
35+
The logs command supports two main operations: listing logs and streaming logs in real-time.
36+
37+
### List Logs
38+
39+
To fetch and display logs:
40+
41+
```bash
42+
sentry-cli logs list --project=my-project --org=my-org
43+
```
44+
45+
### Stream Logs
46+
47+
To continuously stream logs in real-time:
48+
49+
```bash
50+
sentry-cli logs list --project=my-project --org=my-org --live
51+
```
52+
53+
The live streaming mode will continuously poll for new logs and display them as they arrive.
54+
55+
## Command Options
56+
57+
### Project and Organization
58+
59+
Specify the project and organization explicitly:
60+
61+
```bash
62+
sentry-cli logs list --project=my-project --org=my-org
63+
```
64+
65+
Or use the default values from your configuration file.
66+
67+
## Examples
68+
69+
### Monitor Application Logs
70+
71+
Stream logs from your production application:
72+
73+
```bash
74+
sentry-cli logs list --project=my-app --org=my-org --live
75+
```
76+
77+
### View Recent Logs
78+
79+
Fetch and display logs from your project:
80+
81+
```bash
82+
sentry-cli logs list --project=my-app --org=my-org
83+
```
84+
85+
## Output Format
86+
87+
The logs command displays log entries with the following information:
88+
89+
- Timestamp
90+
- Log level
91+
- Message
92+
- Trace ID (if present)
93+
94+
Log entries are displayed in a readable format, making it easy to monitor your application's logging output directly from the command line.

0 commit comments

Comments
 (0)