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
Copy file name to clipboardExpand all lines: develop-docs/sdk/telemetry/spans/batch-processor.mdx
+13-9Lines changed: 13 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,39 +14,43 @@ The BatchProcessor batches spans and logs into one envelope to reduce the number
14
14
15
15
## Specification
16
16
17
-
Whenever the SDK finishes a span or captures a log, it MUST put these into the BatchProcessor. The SDK MUST NOT put unfinished spans into the BatchProcessor. The BatchProcessor MUST start a timeout of `x` seconds when the SDK adds the first span or log. When the timeout exceeds, the BatchProcessor MUST send all spans or logs, no matter how many items it contains. The BatchProcessor MUST send all items after the SDK captures spans or logs with a size more than `y`. When the BatchProcessor sends all spans or logs, it MUST reset its timeout and remove all spans and logs. The SDK MUST apply filtering and sampling before adding spans or logs to the BatchProcessor. The SDK SHOULD drop rate limited spans and logs before putting them into the BatchProcessor to reduce memory usage.
17
+
Whenever the SDK finishes a span or captures a log, it MUST put these into the BatchProcessor. The SDK MUST NOT put unfinished spans into the BatchProcessor.
18
18
19
-
The SDK MUST calculate the size of a span or a log to manage the BatchProcessor's memory footprint. The SDK MUST serialize the span or log and calculate the size based on the serialized JSON bytes. As serialization is expensive, the BatchProcessor SHOULD keep track of the serialized spans and logs and pass these to the envelope to avoid serializing multiple times.
19
+
The BatchProcessor MUST start a timeout of 5 seconds when the SDK adds the first span or log. When the timeout exceeds, the BatchProcessor MUST send all spans or logs, no matter how many items it contains. The SDK MAY choose a different value for the timeout, but it MUST NOT exceed 30 seconds, as this can lead to problems with the span buffer on the backend, which uses a time interval of 60 seconds for determining segments for spans.
20
20
21
-
The detailed specification is written in the [Gherkin syntax](https://cucumber.io/docs/gherkin/reference/) and uses `x = 10` seconds for the timeout and `y = 1024 * 1024` for the maximum batch byte size in the BatchProcessor. SDKs MAY use different values for `x` and `y` depending on their needs. The SDK SHOULD NOT expose x and y via the options. The specification uses spans as an example, but the same applies to logs or any other future telemetry data.
21
+
The BatchProcessor MUST send all items after the SDK when containing spans or logs exceeding 1MiB in size. The SDK MAY choose a different value for the max batch size keeping the [envelope max sizes](/sdk/data-model/envelopes/#size-limits) in mind. The SDK MUST calculate the size of a span or a log to manage the BatchProcessor's memory footprint. The SDK MUST serialize the span or log and calculate the size based on the serialized JSON bytes. As serialization is expensive, the BatchProcessor SHOULD keep track of the serialized spans and logs and pass these to the envelope to avoid serializing multiple times.
22
+
23
+
When the BatchProcessor sends all spans or logs, it MUST reset its timeout and remove all spans and logs. The SDK MUST apply filtering and sampling before adding spans or logs to the BatchProcessor. The SDK SHOULD drop rate limited spans and logs before putting them into the BatchProcessor to reduce memory usage.
24
+
25
+
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.
22
26
23
27
24
28
```Gherkin
25
29
Scenario: No spans in BatchProcessor 1 span added
26
30
Given no spans in the BatchProcessor
27
31
When the SDK finishes 1 span
28
32
Then the SDK puts this span to the BatchProcessor
29
-
And starts a timeout of 10 seconds
33
+
And starts a timeout of 5 seconds
30
34
And doesn't send the span to Sentry
31
35
32
36
Scenario: Span added before timeout exceeds
33
37
Given span A in the BatchProcessor
34
-
Given 9.9 seconds pass
38
+
Given 4.9 seconds pass
35
39
When the SDK finishes span B
36
40
Then the SDK adds span B to the BatchProcessor
37
41
And doesn't reset the timeout
38
42
And doesn't send the spans A and B in the BatchProcessor to Sentry
39
43
40
-
Scenario: Spans with size of y - 1 added, timeout exceeds
41
-
Given spans with size of y - 1 in the BatchProcessor
44
+
Scenario: Spans with size of MiB - 1 byte added, timeout exceeds
45
+
Given spans with size of MiB - 1 byte in the BatchProcessor
42
46
When the timeout exceeds
43
47
Then the SDK adds all the spans to one envelope
44
48
And sends them to Sentry
45
49
And resets the timeout
46
50
And clears the BatchProcessor
47
51
48
-
Scenario: Spans with size of y added within 9.9 seconds
49
-
Given spans with size of y - 1 in the BatchProcessor
52
+
Scenario: Spans with size of MiB - 1 byte added within 4.9 seconds
53
+
Given spans with size of MiB - 1 byte in the BatchProcessor
50
54
When the SDK finishes another span and puts it into the BatchProcessor
51
55
Then the BatchProcessor puts all spans into one envelope
0 commit comments