You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The buffer system sits between the SDK client and the HTTP transport layer, ensuring that critical telemetry like errors take priority over high-volume data like logs and traces. This prevents important events from getting lost when your application is under heavy load or sending large amounts of telemetry.
15
+
The TelemetryProcessor sits between the SDK client and the HTTP transport layer, ensuring that critical telemetry like errors take priority over high-volume data like logs and traces. This prevents important events from getting lost when your application is under heavy load or sending large amounts of telemetry.
12
16
13
17
### Motivation
14
18
15
-
- Aggregation lives in a unified buffer layer (this way we avoid creating multiple batch processors for different telemetry types).
19
+
- Aggregation lives in a unified layer (this way we avoid creating multiple batch processors for different telemetry types).
16
20
- All telemetry types use capture APIs (CaptureX) routed through the Client.
17
21
- Rate-limit awareness is built-in across categories.
18
22
- Buffers support two modes: normal ring buffer and bucket-by-trace (for spans).
19
23
- For spans, dropping an entire trace under pressure is preferable.
20
24
21
25
### Architecture Overview
22
26
23
-
Introduce a `Buffer` layer between the `Client` and the `Transport`. This `Buffer` wraps prioritization and scheduling and exposes a minimal API to the SDK:
27
+
Introduce a `TelemetryProcessor` layer between the `Client` and the `Transport`. This `TelemetryProcessor` wraps prioritization and scheduling and exposes a minimal API to the SDK:
24
28
25
29
- Add(item).
26
30
- Flush(timeout).
@@ -34,19 +38,19 @@ Introduce a `Buffer` layer between the `Client` and the `Transport`. This `Buffe
-**Smart batching**: Logs are batched into single requests; errors, transactions, and monitors are sent immediately.
67
-
-**Pre-send rate limiting**: The scheduler checks rate limits before serialization to avoid unnecessary processing. When a telemetry is rate-limited the selected batch should
71
+
-**Pre-send rate limiting**: The TelemetryScheduler checks rate limits before serialization to avoid unnecessary processing. When a telemetry is rate-limited the selected batch should
68
72
be dropped, to avoid filling up the buffers.
69
73
-**Category isolation**: Separate ring buffers for each telemetry type prevent head-of-line blocking.
70
74
-**Weighted scheduling**: High-priority telemetry gets sent more frequently via round-robin selection.
@@ -81,9 +85,9 @@ Configurable via weights.
81
85
82
86
### Components
83
87
84
-
#### Storage
88
+
#### TelemetryBuffers
85
89
86
-
Each telemetry category maintains a store interface; a fixed-size circular array/ring buffer (not to be confused with the `Buffer` wrapper) that stores items before transmission:
90
+
Each telemetry category maintains a buffer interface; a fixed-size circular array/ring buffer that stores items before transmission:
87
91
88
92
-**Bounded capacity**: Default to 100 items for errors, logs, and monitors; 1000 for transactions. This prevents unbounded memory growth regardless of telemetry volume and backpressure handling.
89
93
-**Overflow policies** (optional):
@@ -100,10 +104,10 @@ Each telemetry category maintains a store interface; a fixed-size circular array
100
104
- Offer semantics: if not full, append; when full, apply `overflowPolicy`:
101
105
-`drop_oldest`: evict the oldest item, insert the new one, and invoke the dropped callback with reason `buffer_full_drop_oldest`.
102
106
-`drop_newest`: reject the new item and invoke the dropped callback with reason `buffer_full_drop_newest`.
103
-
- Readiness: a store is ready when `size >= batchSize` or when `timeout` has elapsed since `lastFlushTime` (and it is non-empty).
104
-
- Polling: `PollIfReady()` returns up to `batchSize` items and updates `lastFlushTime`; `Drain()` empties the store.
107
+
- Readiness: a buffer is ready when `size >= batchSize` or when `timeout` has elapsed since `lastFlushTime` (and it is non-empty).
108
+
- Polling: `PollIfReady()` returns up to `batchSize` items and updates `lastFlushTime`; `Drain()` empties the buffer.
105
109
106
-
##### Bucketed-by-trace storage (spans)
110
+
##### Bucketed-by-trace buffer (spans)
107
111
108
112
-**Purpose**: keep spans from the same trace together and flush them as a unit to avoid partial-trace delivery under pressure. This addresses a gap in standard implementations where individual span drops can create incomplete traces.
109
113
-**Grouping**: a new bucket is created per trace id; a map (`traceIndex`) provides O(1) lookup.
@@ -119,11 +123,11 @@ Each telemetry category maintains a store interface; a fixed-size circular array
119
123
There still remains a small subset of cases that might result in partial traces, where either an old trace bucket was dropped and a new span with the same trace arrived, or we dropped an incoming span of this trace.
120
124
The preferred overflow behavior in most cases should be `drop_oldest` since it results in the fewest incomplete traces from the two scenarios.
121
125
122
-
Stores are mapped to [DataCategories](https://github.com/getsentry/relay/blob/master/relay-base-schema/src/data_category.rs), which determine their scheduling priority and rate limits.
126
+
Buffers are mapped to [DataCategories](https://github.com/getsentry/relay/blob/master/relay-base-schema/src/data_category.rs), which determine their scheduling priority and rate limits.
123
127
124
-
#### Scheduler
128
+
#### TelemetryScheduler
125
129
126
-
The scheduler runs as a background worker, coordinating the flow of telemetry from storage to the transport:
130
+
The TelemetryScheduler runs as a background worker, coordinating the flow of telemetry from buffers to the transport:
127
131
128
132
-**Initialization**: Constructs a weighted priority cycle (e.g., `[CRITICAL×5, HIGH×4, MEDIUM×3, ...]`) based on configured weights.
129
133
-**Event loop**: Wakes when explicitly signaled from the `captureX` methods on the client when new data is available (if the language does not support this, then a periodic ticker can be used).
@@ -191,7 +195,7 @@ type Storage[T any] interface {
The BatchProcessor is deprecated. Please use the [Telemetry Buffer](/sdk/telemetry/telemetry-buffer/) instead.
10
+
The BatchProcessor is deprecated. Please use the [Telemetry Processor](/sdk/telemetry/telemetry-processor/) instead.
10
11
</Alert>
11
12
12
13
<Alert>
@@ -15,7 +16,7 @@ sidebar_order: 10
15
16
16
17
# BatchProcessor (deprecated)
17
18
18
-
This section covers the initial specification of the BatchProcessor, which some SDKs use as a reference when implementing logs. This exists only as a reference until we fully spec out the [telemetry buffer](/sdk/telemetry/telemetry-buffer/) across all platforms.
19
+
This section covers the initial specification of the BatchProcessor, which some SDKs use as a reference when implementing logs. This exists only as a reference until we fully spec out the [telemetry processor](/sdk/telemetry/telemetry-processor/) across all platforms.
19
20
20
21
## Overview
21
22
@@ -37,7 +38,7 @@ The BatchProcessor **MUST** forward all spans and logs in memory to the transpor
37
38
2. When the user calls `SentrySDK.close()`, the BatchProcessor **MUST** forward all data in memory to the transport. SDKs **SHOULD** keep their existing closing behavior.
38
39
3. When the application shuts down gracefully, the BatchProcessor **SHOULD** forward all data in memory to the transport. The transport **SHOULD** keep its existing behavior, which usually stores the data to disk as an envelope. It is not required to call a transport `flush`. This is mostly relevant for mobile SDKs already subscribed to these hooks, such as [applicationWillTerminate](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/applicationwillterminate(_:)) on iOS.
39
40
4. When the application moves to the background, the BatchProcessor **SHOULD** forward all the data in memory to the transport and stop the timer. The transport **SHOULD** keep its existing behavior, which usually stores the data to disk as an envelope. It is not required to call the transport `flush`. This is mostly relevant for mobile SDKs.
40
-
5. Mobile SDKs **MUST** minimize data loss when sudden process terminations occur. Refer to the [Mobile Telemetry Buffer](/sdk/telemetry/telemetry-buffer/mobile-telemetry-buffer) section for more details.
41
+
5. Mobile SDKs **MUST** minimize data loss when sudden process terminations occur. Refer to the [Mobile Telemetry Processor](/sdk/telemetry/telemetry-processor/mobile-telemetry-processor) section for more details.
41
42
42
43
The detailed specification is written in the [Gherkin syntax](https://cucumber.io/docs/gherkin/reference/). The specification uses spans as an example, but the same applies to logs or any other future telemetry data.
0 commit comments