find_dropped_events doesn't say that buckets snap to whole intervals

未關閉 適合新手
#2,276 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
文件
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript

研究方向

從 packages/mcp-core/src/tools/catalog/find-dropped-events.ts 開始:interval 的提示文字位於第 83-84 行和第 128-137 行附近,而省略 meta.start/meta.end 的回應映射位於第 212-217 行。追蹤此工具如何建構其結果,以便在 start/end 超出 interval 邊界時新增條件式註記,然後執行此工具的測試,確認新的提示與註記會出現。

由索引模型根據 Issue 內容生成。

描述

MCP mcp-feedback-pattern

Pattern: find_dropped_events with start/end and a coarse interval returns full-interval volumes for the first and last buckets, not volumes for the requested window. Nothing in the tool output or the description says so. Callers that sum the buckets for a fixed window overcount.

Reports: 1 (Sentry MCP user feedback MCP-SERVER-GQD, python caller, server 0.42.0). The caller worked around it with interval=1h and told its user about the alignment limit.

What happens

  1. The caller passes start=<…T18:01Z>, end=<…T06:01Z>, interval=1d. The tool forwards them unchanged to GET /organizations/{org}/events-dropped/ (sampled span for this caller's call).
  2. Sentry builds the outcomes query through QueryDefinition → get_constrained_date_range (getsentry/sentry src/sentry/snuba/sessions_v2.py:451-487), which calls to_intervals (src/sentry/snuba/metrics/utils.py:414-449). That floors start to the interval and rounds end up to the next boundary. With 1d, the range becomes <day>T00:00Z to <last day + 1>T00:00Z. So the first and last buckets hold whole-day totals.
  3. The endpoint's meta.start / meta.end report the requested range, not the aligned one (src/sentry/api/endpoints/organization_events_dropped.py:233-234). The MCP tool doesn't return meta.start/meta.end at all (packages/mcp-core/src/tools/catalog/find-dropped-events.ts:212-217). Only each bucket's own start/end gives this away.
  4. The description (find-dropped-events.ts:83-84, :128-137) tells callers to "use '1d' and sum the buckets" for longer ranges, without saying that the first and last buckets can cover time outside the window.

Suggested fix (MCP side)

  • When start/end don't fall on interval boundaries, add a note that gives the aligned range that was counted and says the edge buckets are whole intervals. Suggest a finer interval (for example 1h) for exact windows.
  • Add one line to the interval hint saying buckets align to whole intervals in UTC.

Possible Sentry API follow-up (not filed): meta.start/meta.end could report the aligned range that was actually queried. Owner: whoever owns organization_events_dropped.py. The MCP note above doesn't depend on that change.

Not this issue: the same report's search_errors time-range problem is getsentry/toolkit#2146, and its explanation mismatch is getsentry/toolkit#2147.

via automation evt_905b9c478746fd9deeb853f85ad7441b · Run ID dispatch_ebd17b42670133526c625ae4ebab5254.

--

View Session [Sentry]

主要語言
TypeScript
星號
961
分支
179
平均合併
15 小時 33 分鐘
30 天內合併 PR
476

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/toolkit 的其他 Issue

查看 getsentry/toolkit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。