Skip to content

Conversation

@denrase
Copy link
Collaborator

@denrase denrase commented Nov 13, 2025

📜 Description

This took some digging. I was testing sending logs in a tight loop and got rejected by the backend.

[Sentry] [debug] [1763038665.309155] [SentryRequestOperation:36] Request status: 400
[Sentry] [debug] [1763038665.309175] [SentryRequestOperation:42] Request response: {"detail":"envelope exceeded size limits for type 'log' (https://develop.sentry.dev/sdk/envelopes/#size-limits)"}

So I checked replay code. The issue is that it has 1000 logs MAX item limit, which is not in any documentation we used when implementing the log batching. Its documented here (https://develop.sentry.dev/sdk/telemetry/logs/#buffering)

Another issue I saw during testing is that envelopes persisted with > 1000 log items are being re-tried, so this is something that clients out there may be experiencing.

💡 Motivation and Context

Log envelopes dropped by the backend.

💚 How did you test it?

Unit tests. Sample app.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

Closes #6770

@denrase denrase changed the title Fix: Batch MAX 1000 logs Limit log batching to maximum 1000 logs per batch Nov 13, 2025
@denrase denrase marked this pull request as ready for review November 13, 2025 14:15
@denrase denrase added the ready-to-merge Use this label to trigger all PR workflows label Nov 13, 2025
@denrase
Copy link
Collaborator Author

denrase commented Nov 13, 2025

@philipphofmann @noahsmartin I'm thinking if we should also drop individual log item > 1MB or prune large attributes. WDYT?

@denrase denrase requested a review from itaybre November 13, 2025 14:26
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.884%. Comparing base (402fe24) to head (422b652).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #6768       +/-   ##
=============================================
- Coverage   84.896%   84.884%   -0.013%     
=============================================
  Files          453       453               
  Lines        27597     27600        +3     
  Branches     12101     12104        +3     
=============================================
- Hits         23429     23428        -1     
- Misses        4123      4127        +4     
  Partials        45        45               
Files with missing lines Coverage Δ
Sources/Swift/Tools/SentryLogBatcher.swift 98.461% <100.000%> (+0.036%) ⬆️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 402fe24...422b652. Read the comment docs.

@cleptric
Copy link
Member

Let's please cap this at 100, as in https://develop.sentry.dev/sdk/telemetry/logs/#buffering.
We can always raise limits at a later date, but lowering them is hard.
Yes, Relay technically allows up to 1000 items, but we aligned on 100 across SDKs.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1214.40 ms 1264.69 ms 50.29 ms
Size 24.14 KiB 1.01 MiB 1014.72 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4bf98bf 1219.13 ms 1244.50 ms 25.38 ms
5cbd333 1220.78 ms 1234.15 ms 13.36 ms
c174e5e 1209.65 ms 1238.73 ms 29.08 ms
5aa3ce5 1222.78 ms 1245.39 ms 22.61 ms
be882e4 1199.35 ms 1231.20 ms 31.86 ms
86eb6d5 1224.95 ms 1251.82 ms 26.87 ms
9c75c11 1228.42 ms 1262.81 ms 34.39 ms
d0f70ce 1226.54 ms 1247.04 ms 20.50 ms
9ccc0f5 1227.59 ms 1264.07 ms 36.47 ms
e36128b 1213.04 ms 1248.60 ms 35.56 ms

App size

Revision Plain With Sentry Diff
4bf98bf 23.75 KiB 919.70 KiB 895.95 KiB
5cbd333 23.74 KiB 969.66 KiB 945.92 KiB
c174e5e 23.75 KiB 953.92 KiB 930.16 KiB
5aa3ce5 23.75 KiB 904.54 KiB 880.79 KiB
be882e4 23.75 KiB 946.69 KiB 922.94 KiB
86eb6d5 23.74 KiB 1.02 MiB 1016.53 KiB
9c75c11 23.74 KiB 1022.95 KiB 999.20 KiB
d0f70ce 23.75 KiB 913.09 KiB 889.34 KiB
9ccc0f5 24.14 KiB 1.01 MiB 1014.11 KiB
e36128b 23.75 KiB 963.19 KiB 939.44 KiB

Previous results on branch: fix/introduce-log-count-limit

Startup times

Revision Plain With Sentry Diff
e29802f 1214.73 ms 1243.87 ms 29.14 ms

App size

Revision Plain With Sentry Diff
e29802f 24.14 KiB 1.01 MiB 1014.03 KiB

@denrase denrase changed the title Limit log batching to maximum 1000 logs per batch Limit log batching to maximum 100 logs per batch Nov 13, 2025
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@denrase denrase enabled auto-merge (squash) November 13, 2025 15:57
@philipphofmann
Copy link
Member

Let's please cap this at 100, as in https://develop.sentry.dev/sdk/telemetry/logs/#buffering. We can always raise limits at a later date, but lowering them is hard. Yes, Relay technically allows up to 1000 items, but we aligned on 100 across SDKs.

I also added this as recommendation to getsentry/sentry-docs#15513

@denrase denrase merged commit ed6b6f3 into main Nov 17, 2025
189 of 193 checks passed
@denrase denrase deleted the fix/introduce-log-count-limit branch November 17, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit log batching to maximum 100 logs per batch

5 participants