Skip to content

Commit a4b8032

Browse files
authored
Merge branch 'master' into ab/supabase-integration
2 parents 1c283ce + 5167542 commit a4b8032

File tree

13 files changed

+239
-15
lines changed

13 files changed

+239
-15
lines changed

.github/workflows/lint-404s.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [master]
88

99
jobs:
10-
index:
10+
lint-404:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Span API
3+
---
4+
5+
<Alert level="info">
6+
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.
7+
</Alert>
8+
9+
<Alert level="info">
10+
The APIs specified in this document MUST be implemented by all SDKs that don't use OpenTelemetry as their underlying tracing implementation.
11+
SDKs using OTel SHOULD follow their own already established span APIs but MAY orient themselves on this document if applicable.
12+
</Alert>
13+
14+
Spans are measuring the duration of certain operations in an application.
15+
16+
The topmost member of a (distributed) span tree is called the "Root Span".
17+
This span has no parent span and groups together its children with a representative name for the entire operation, such as `GET /` in case of a request to a backend application.
18+
19+
The topmost span within a service boundary is called the "Segment Span".
20+
Segment spans have a `parent_span_id` pointing to a "remote" span from the parent service.
21+
22+
For example, a distributed trace from backend to frontend, would have a segment span for the backend, and a segment span for the frontend.
23+
The frontend segment span is also the root span of the entire span tree.
24+
25+
SDKs MUST NOT expose names like "segment span" (e.g. in APIs) to users and SHOULD NOT (read "avoid") exposing "root span" if possible.
26+
27+
## Span Interface
28+
29+
SDKs' span implementations MUST at minimum implement the following span interface.
30+
31+
```ts
32+
interface Span {
33+
private _spanId: string;
34+
35+
end(endTimestamp?: SpanTimeInput): void;
36+
37+
setAttribute(key: string, value: SpanAttributeValue | undefined): this;
38+
setAttributes(attributes: SpanAttributes): this;
39+
40+
setStatus(status: 'ok' | 'error'): this;
41+
42+
setName(name: string): this;
43+
44+
addLink(link: SpanLink): this;
45+
addLinks(links: SpanLink[]): this;
46+
47+
getName(): string;
48+
getAttributes(): Record<string, SpanAttributeValue>
49+
}
50+
```
51+
52+
When implementing the span interface, consider the following guidelines:
53+
54+
- SDKs MAY implement additional APIs, such as getters/setters for properties (e.g. `span.getStatus()`), or additional methods for convenience (e.g. `Span::spanContext()`).
55+
- SDK implementers SHOULD disallow direct mutation (without setters) of span properties such as the span name, depending on the platform and the challenges involved.
56+
- SDK implementers MAY disallow direct read access to span properties, depending on the platform and the challenges involved.
57+
58+
## Span Starting APIs
59+
60+
SDKs MUST expose at least one API to start a span. SDKs MAY expose additional APIs, depending on the platform, language conventions and requirements.
61+
62+
### Default `startSpan` API
63+
64+
SDKs MUST expose a default `startSpan` API that takes options and returns a span:
65+
66+
```ts
67+
function startSpan(options: StartSpanOptions): Span;
68+
69+
interface StartSpanOptions {
70+
name: string;
71+
attributes?: Record<string, SpanAttributeValue>;
72+
parentSpan?: Span | null;
73+
active?: boolean;
74+
}
75+
```
76+
77+
SDKs MUST allow specifying the following options to be passed to `startSpan`:
78+
79+
| Option | Required | Description |
80+
|---------------|----------|----------------------------------------------|
81+
| `name` | Yes | The name of the span. MUST be set by users |
82+
| `attributes` | No | Attributes to attach to the span. |
83+
| `parentSpan` | No | The parent span. See description below for implications of allowed values |
84+
| `active` | No | Whether the started span should be _active_ (i.e. if spans started while this span is active should become children of the started span). |
85+
86+
Behaviour:
87+
- Spans MUST be started as active by default. This means that any span started, while the initial span is active, MUST be attached as a child span of the active span.
88+
- Only if users set `active: false`, the span will be started as inactive, meaning spans started while this span is not yet ended, will not become children, but siblings of the started span.
89+
- If a `Span` is passed via `parentSpan`, the span will be started as the child of the passed parent span. This has precedence over the currently active span.
90+
- If `null` is passed via `parentSpan`, the new span will be started as a root/segment span.
91+
- SDKs MUST NOT end the span automatically. This is the responsibility of the user.
92+
- `startSpan` MUST always return a span instance, even if the started span's trace is negatively sampled.
93+
94+
95+
### Additional Span Starting APIs
96+
97+
SDKs MAY expose additional span starting APIs or variants of `startSpan` that make sense for the platform.
98+
These could be decorators, annotations, or closure- or callback-based APIs.
99+
Additional APIs MAY e.g. end spans automatically (for example, when a callback terminates, the span is ended automatically).
100+
Likewise, additional APIs MAY also adjust the span status based on errors thrown.
101+
102+
### Explicitly creating a child span
103+
104+
At this time, SDKs MUST NOT expose APIs like `Span::startChild` or similar functionality that explicitly creates a child span.
105+
This is still TBD but the `parentSpan` option should suffice to serve this use case.
106+
107+
## Utility APIs
108+
109+
SDKs MAY expose additional utility APIs for users, or internal usage to access certain spans. For example,
110+
111+
- `Scope::getSpan()` - returns the currently active span.
112+
- `Scope::_INTERNAL_getSegmentSpan()` - returns the segment span of the currently active span (MUST NOT be documented for users)
113+
114+
## Example
115+
116+
```ts
117+
118+
const checkoutSpan = Sentry.startSpan({ name: 'on-checkout-click', attributes: { 'user.id': '123' } })
119+
120+
const validationSpan = Sentry.startSpan({ name: 'validate-shopping-cart'})
121+
startFormValidation().then((result) => {
122+
validationSpan.setAttribute('valid-form-data', result.success);
123+
processSpan.end();
124+
})
125+
126+
const processSpan = Sentry.startSpan({ name: 'process-order', parentSpan: checkoutSpan});
127+
processOrder().then((result) => {
128+
processSpan.setAttribute('order-processed', result.success);
129+
processSpan.end();
130+
}).catch((error) => {
131+
processSpan.setStatus('error');
132+
processSpan.setAttribute('error', error.message);
133+
processSpan.end();
134+
});
135+
136+
const unrelatedSpan = Sentry.startSpan({ name: 'log-order', parentSpan: null});
137+
logOrder()
138+
unrelatedSpan.end();
139+
140+
on('checkout-finished', ({ timestamp }) => {
141+
checkoutSpan.end(timestamp);
142+
})
143+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Span Trace Propagation
3+
---
4+
5+
<Alert level="info">
6+
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.
7+
</Alert>
8+
9+
## Continue an incoming trace
10+
11+
To continue a trace from an upstream service, the SDK must expose a method to extract the traceparent and baggage information and apply these to the applicable scope.
12+
13+
```js
14+
scope.setPropagationContext({
15+
traceparent: request.headers.SENTRY_TRACE,
16+
baggage: request.headers.SENTRY_BAGGAGE,
17+
})
18+
```
19+
Newly created root spans should now contain these properties, such as `trace_id` and `parent_span_id`.
20+
21+
## Continue an outgoing trace
22+
23+
To propagate a trace to a downstream service, the SDK must expose methods to fetch the required information to allow the next service to continue the trace.
24+
25+
```js
26+
traceparent = scope.getTraceparent()
27+
baggage = scope.getBaggage()
28+
```

docs/platforms/dart/guides/flutter/troubleshooting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This happens because Dart's async/await implementation can cause stack trace inf
5757
### What Can You Do?
5858

5959
In order to get better debugging information for these cases you can:
60-
- Add relevant context to your Sentry events using [custom tags](/platforms/dart/guides/flutter/data-management/tags/) and [breadcrumbs](/platforms/dart/guides/flutter/data-management/breadcrumbs/) for critical paths in your application
60+
- Add relevant context to your Sentry events using [custom tags](/platforms/dart/guides/flutter/enriching-events/tags/) and [breadcrumbs](/platforms/dart/guides/flutter/enriching-events/breadcrumbs/) for critical paths in your application
6161
- Consider using [Sentry's Structured Logs](/platforms/dart/logs/) to capture additional debugging data alongside your errors
6262

6363
## Support 16 KB Page Sizes on Android

docs/platforms/javascript/guides/aws-lambda/install/cjs-npm__v9.x.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In this guide you will learn how to set up the `@sentry/aws-serverless` SDK for
1111
We recommend starting the SDK automatically via environment variables so that you only have to make minimal code changes to your lambda function.
1212
If you need more control over the SDK setup, you can also [initialize the SDK in in code](#alternative-initialize-the-sdk-in-code).
1313

14-
However, you need to modify your code and deploy the Sentry dependencies alongside your function code. If you're looking for the most simple way to set up Sentry, you might want to use the [Lambda Layer](./layer__v9.x) instead.
14+
However, you need to modify your code and deploy the Sentry dependencies alongside your function code. If you're looking for the most simple way to set up Sentry, you might want to use the [Lambda Layer](./layer__v9.x.mdx) instead.
1515

1616
## 1. Prerequisites
1717

docs/platforms/javascript/guides/aws-lambda/install/index__v9.x.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Note that TypeScript can also be configured to output ESM, in which case you sho
1818

1919
### My Lambda function uses `require`
2020

21-
If you are using `require()` in your function, follow the CommonJS instructions. Choose between [using our Lambda Layer (recommended)](./install/layer__v9.x) or [installing the Sentry AWS NPM package](./install/npm__v9.x).
21+
If you are using `require()` in your function, follow the CommonJS instructions. Choose between [using our Lambda Layer (recommended)](./install/layer__v9.x.mdx) or [installing the Sentry AWS NPM package](./install/npm__v9.x.mdx).
2222

2323
### My Lambda function uses `import`
2424

25-
If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./install/esm-npm__v9.x).
25+
If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./install/esm-npm__v9.x.mdx).
2626

2727
### Can I use the Lambda layer for ESM functions?
2828

docs/platforms/javascript/guides/aws-lambda/install/layer__v8.x.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ noindex: true
88
og_image: /og-images/platforms-javascript-guides-aws-lambda-install-layer__v8.x.png
99
---
1010

11-
The easiest way to get started with Sentry is to use the Sentry [Lambda Layer](https://docs.aws.amazon.com/Lambda/latest/dg/configuration-layers.html) instead of adding `@sentry/aws-serverless` with `npm` or `yarn` [manually](../install/npm).
11+
The easiest way to get started with Sentry is to use the Sentry [Lambda Layer](https://docs.aws.amazon.com/Lambda/latest/dg/configuration-layers.html) instead of adding `@sentry/aws-serverless` with `npm` or `yarn` [manually](../install/npm.mdx).
1212
If you follow this guide, you don't have to worry about deploying Sentry dependencies alongside your function code.
1313
To actually start the SDK, you can decide between setting up the SDK using environment variables or in your Lambda function code. We recommend using environment variables as it's the easiest way to get started. [Initializing the SDK in code](#alternative-initialize-the-sdk-in-code) instead of setting environment variables gives you more control over the SDK setup if you need it.
1414

1515
<Alert>
1616

17-
This installation method **does not** work with Lambda functions running in EcmaScript Modules (ESM) mode, using `import` syntax. If you're running your function in ESM, follow the [ESM guide](../install/npm).
17+
This installation method **does not** work with Lambda functions running in EcmaScript Modules (ESM) mode, using `import` syntax. If you're running your function in ESM, follow the [ESM guide](../install/npm.mdx).
1818

1919
</Alert>
2020

docs/platforms/javascript/guides/aws-lambda/install/layer__v9.x.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ sidebar_order: 1
77
og_image: /og-images/platforms-javascript-guides-aws-lambda-install-layer__v9.x.png
88
---
99

10-
The easiest way to get started with Sentry is to use the Sentry [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/adding-layers.html) instead of adding `@sentry/aws-serverless` with `npm` or `yarn` [manually](./npm__v9.x).
10+
The easiest way to get started with Sentry is to use the Sentry [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/adding-layers.html) instead of adding `@sentry/aws-serverless` with `npm` or `yarn` [manually](./npm__v9.x.mdx).
1111
If you follow this guide, you don't have to worry about deploying Sentry dependencies alongside your function code.
1212
To actually start the SDK, you can decide between setting up the SDK using environment variables or in your Lambda function code. We recommend using environment variables as it's the easiest way to get started. [Initializing the SDK in code](#alternative-initialize-the-sdk-in-code) instead of setting environment variables gives you more control over the SDK setup if you need it.
1313

1414
<Alert>
1515

16-
This installation method **does not** work with Lambda functions running in EcmaScript Modules (ESM) mode, using `import` syntax. If you're running your function in ESM, follow the [ESM guide](../npm__v9.x).
16+
This installation method **does not** work with Lambda functions running in EcmaScript Modules (ESM) mode, using `import` syntax. If you're running your function in ESM, follow the [ESM guide](../npm__v9.x.mdx).
1717

1818
</Alert>
1919

docs/platforms/javascript/guides/aws-lambda/install/npm__v9.x.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Based on whether your Lambda function runs in CommonJS or ESM, you need to follo
88

99
## My Lambda function is written in TypeScript
1010

11-
If you're using TypeScript, your lambda function is likely transpiled to CommonJS before running it. In this case, follow the [CommonJS instructions](./cjs-npm__v9.x).
12-
Note that TypeScript can also be configured to output ESM, in which case you should follow the [ESM instructions](./esm-npm__v9.x).
11+
If you're using TypeScript, your lambda function is likely transpiled to CommonJS before running it. In this case, follow the [CommonJS instructions](./cjs-npm__v9.x.mdx).
12+
Note that TypeScript can also be configured to output ESM, in which case you should follow the [ESM instructions](./esm-npm__v9.x.mdx).
1313

1414
## My Lambda function uses `require`
1515

16-
If you are using `require()` in your function, follow the [CommonJS instructions](./cjs-npm__v9.x).
16+
If you are using `require()` in your function, follow the [CommonJS instructions](./cjs-npm__v9.x.mdx).
1717

1818
## My Lambda function uses `import`
1919

20-
If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./esm-npm__v9.x).
20+
If you're using `import` syntax in your function and you're _not_ transpiling the code to CommonJS, follow the [ESM instructions](./esm-npm__v9.x.mdx).

docs/platforms/react-native/session-replay/index.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,33 @@ If you encounter any data not being redacted with the default settings, please l
150150

151151
</Alert>
152152

153+
### Screenshot Strategy (Android only)
154+
155+
_Available in version 7.5.0 of the React Native SDK_
156+
157+
The SDK offers two strategies for recording replays on Android: `PixelCopy` and `Canvas`.
158+
159+
`PixelCopy` uses Android's [PixelCopy](https://developer.android.com/reference/android/view/PixelCopy) API to capture screenshots of the current screen and takes a snapshot of the view hierarchy within the same frame. The view hierarchy is then used to find the position of controls such as text boxes, images, labels, and buttons and mask them with a block that's drawn over these controls. This strategy has slightly lower performance overhead but may result in masking misalignments due to the asynchronous nature of the PixelCopy API. We recommend using this strategy for apps that do not have strict PII requirements or do not require masking functionality.
160+
161+
`Canvas` uses Android's custom [Canvas](https://developer.android.com/reference/android/graphics/Canvas) API to redraw the screen contents onto a bitmap, masking all `drawText` and `drawBitmap` operations in the process to produce a masked screenshot. This strategy has a slightly higher performance overhead but provides more reliable masking. We recommend using this strategy for apps with strict PII requirements.
162+
163+
<Alert level="warning">
164+
165+
The `Canvas` screenshot strategy is currently experimental and does **not** support any masking options. When the screenshot strategy is set to `Canvas`, it will **always** mask all texts, input fields and images, disregarding any masking options set. If you need more flexibility with masking, switch back to `PixelCopy`.
166+
167+
</Alert>
168+
169+
You can change the strategy as follows:
170+
171+
```javascript {tabTitle:Mobile}
172+
integrations: [
173+
// You can pass options to the mobileReplayIntegration function during init:
174+
Sentry.mobileReplayIntegration({
175+
screenshotStrategy: 'canvas' // or 'pixelCopy' (default)
176+
}),
177+
]
178+
```
179+
153180
## React Component Names
154181

155182
Sentry helps you capture your React components and unlock additional insights in your application. You can set it up to use React component names.

0 commit comments

Comments
 (0)