Skip to content

Commit b04356e

Browse files
timeout and max size
1 parent 6c5edb9 commit b04356e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

develop-docs/sdk/telemetry/spans/batch-processor.mdx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,43 @@ The BatchProcessor batches spans and logs into one envelope to reduce the number
1414

1515
## Specification
1616

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.
1818

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.
2020

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.
2226

2327

2428
```Gherkin
2529
Scenario: No spans in BatchProcessor 1 span added
2630
Given no spans in the BatchProcessor
2731
When the SDK finishes 1 span
2832
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
3034
And doesn't send the span to Sentry
3135
3236
Scenario: Span added before timeout exceeds
3337
Given span A in the BatchProcessor
34-
Given 9.9 seconds pass
38+
Given 4.9 seconds pass
3539
When the SDK finishes span B
3640
Then the SDK adds span B to the BatchProcessor
3741
And doesn't reset the timeout
3842
And doesn't send the spans A and B in the BatchProcessor to Sentry
3943
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
4246
When the timeout exceeds
4347
Then the SDK adds all the spans to one envelope
4448
And sends them to Sentry
4549
And resets the timeout
4650
And clears the BatchProcessor
4751
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
5054
When the SDK finishes another span and puts it into the BatchProcessor
5155
Then the BatchProcessor puts all spans into one envelope
5256
And sends the envelope to Sentry

0 commit comments

Comments
 (0)