Callback error isolation: remaining gaps after #5607 and #5610
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 32/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- csharp, java, objective-c, swift
調査の方向性
Start by separating the independent allocation fix in ThreadsafeCounterDictionary.cs from the callback-isolation gaps in SentryClient.cs and SentryEventHelper.cs. Read the linked upstream Java and Cocoa issues before investigating native-event behavior. Done means each selected gap has a decided scope, callback errors are logged and counted as specified, and the relevant tests or measurements confirm the result.
索引モデルが issue の本文から書いたものです。
説明
Follow-up to #5535. #5606, #5607 and #5610 isolate the managed callbacks and count what they drop: callback_error for a throw, the usual reason for a null return. This tracks what's left. Most of it is on native events, where the native SDK does the counting.
Spec: hooks spec 1.1.0 (candidate). When a callback fails, SDKs MUST log an error naming the callback, SHOULD drop the data passed to it, and SHOULD record a callback_error client report.
- 1. iOS native events are counted twice (needs a decision)
- 2. Native events can't be counted as
callback_error(blocked on getsentry/sentry-java#6141 and getsentry/sentry-cocoa#8993) - 3. Exception filters and exception processors aren't isolated
- 4. SDK event processors are counted as
callback_error(minor) - 5. Each recorded drop allocates 24 B (independent, small)
1. iOS native events are counted twice
On iOS, ProcessOnBeforeSend runs the managed event processors and BeforeSend on native events:
https://github.com/getsentry/sentry-dotnet/blob/f55e72eeb2f7c7cc980a4caa727f01249683b80c/src/Sentry/Platforms/Cocoa/SentrySdk.cs#L315-L321
SentryEventHelper records the drop:
https://github.com/getsentry/sentry-dotnet/blob/f55e72eeb2f7c7cc980a4caa727f01249683b80c/src/Sentry/Internal/SentryEventHelper.cs#L26-L60
.NET then returns nil, and sentry-cocoa records before_send for the same event:
https://github.com/getsentry/sentry-cocoa/blob/9.29.2/Sources/Sentry/SentryClient.m#L1164-L1172
| Native event dropped because | .NET counts | sentry-cocoa counts |
|---|---|---|
Event processor returns null |
event_processor |
before_send |
| Event processor throws | callback_error |
before_send |
BeforeSend returns null |
before_send |
before_send |
BeforeSend throws |
callback_error |
before_send |
Main already double-counts a null return. For a throw, the two counts now also disagree on the reason.
Needs a decision. Skipping the .NET record for native events fixes the double count, but then a throw on a native iOS event only ever shows up as before_send, until 2 is done.
2. Native events can't be counted as callback_error
Neither native SDK has the reason yet: sentry-java 8.58.0 (DiscardReason.java) and sentry-cocoa 9.29.2 (SentryDiscardReason.swift).
- Android: when the user's
BeforeSendthrows, #5610'sBeforeSendWrapperreturnsnull(Platforms/Android/SentrySdk.cs:246-255). sentry-java then countsbefore_send/error(SentryClient.java:171-177). - iOS: see 1.
Upstream work:
- getsentry/sentry-java#6141 (part of getsentry/sentry-java#6081) adds
DiscardReason.CALLBACK_ERRORand records it when abeforeSend*callback throws. sentry-java already drops the event on a throw; it just counts it asbefore_sendtoday. - getsentry/sentry-cocoa#8993 plans an
@try/@catchboundary aroundSentryObjCcallbacks, which is the layer the .NET bindings use, and client reports for failures that drop telemetry.
To investigate once those ship: instead of returning null, the bridges could pass the failure through to the native SDK, by throwing a Java exception from BeforeSendCallback.Execute or an NSException from the Cocoa block. The native SDK would then drop the event and count callback_error itself, and .NET could stop recording for native events, which also fixes 1. This depends on how .NET for Android and .NET for iOS marshal managed exceptions across JNI and Objective-C, which needs checking on a device.
3. Exception filters and exception processors aren't isolated
IExceptionFilter.Filter (SentryClient.cs:449) and ISentryEventExceptionProcessor.Process (SentryClient.cs:364-367) have no try/catch of their own. A throw ends in SentryClient.CaptureEvent's catch-all (SentryClient.cs:84). The event is dropped and nothing is counted. The log, An error occurred when capturing the event '{0}'., doesn't name the callback.
That misses the spec's MUST (log naming the callback) and its SHOULD (callback_error). It's a managed-only fix, following the per-processor catch in SentryEventHelper.ProcessEvent.
4. SDK event processors are counted as callback_error (minor)
SentryEventHelper.ProcessEvent catches every event processor, the SDK's own included. The spec only requires isolating user-registered processors. A bug in an SDK processor would show up in the user's Stats as their callback failing. getsentry/sentry-java#6162 marks SDK-owned processors to tell them apart, which is one way to do it.
5. Each recorded drop allocates 24 B
ThreadsafeCounterDictionary.Add and Increment call _items.GetOrAdd(key, new CounterItem()) (ThreadsafeCounterDictionary.cs:27,33). That allocates a CounterItem on every call, even when the key already exists. #5607 adds call sites on hot paths, such as every dropped log or metric.
Measured: a dropped log went from 0 B to 24 B allocated. The factory overload, GetOrAdd(key, static _ => new CounterItem()), brings it back to 0 B. CollectionsExtensions.cs:10 already uses the factory overload. This one is independent of the rest and can be a small PR off main.
- 主要言語
- C#
- スター
- 775
- フォーク
- 262
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 118
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-dotnet のほかの issue
-
chore: remove stale IL3050/IL3053 workaround from the iOS sample対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンState: Needs Discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-dotnet#6071 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Heap dumps: every SDK shutdown logs "Error waiting for GarbageCollectionMonitor task to complete"対応中かも @pcbeingused33 が今日担当しました。 オープンState: Needs Discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-dotnet#6039 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
.NET Platform: Android Task
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-dotnet#6020 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Move the Blazor WebAssembly sample off the deprecated DevServer対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン.NET Framework: Blazor
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
getsentry/sentry-dotnet#5906 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Docs MSBuild Needs Docs Update
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-dotnet#5691 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-dotnet の issue をすべて見る
似ている issue
-
In-car displays show 0 km/h and P while the AV drives対応中かも @bazilinskyy が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
bazilinskyy/coupled-sim#366 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
BaryoDev/umbraco-pwa#196 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
microsoft/fluentui-blazor#5688 ·
メンテナーはふだん 1 日以内に返信
-
bug flaky lsp-transport small
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信