Skip to content

feat(cogs): Granularize measurements - #2114

Open
elramen wants to merge 1 commit into
masterfrom
elramen-cogssplit
Open

elramen wants to merge 1 commit into
masterfrom
elramen-cogssplit

Conversation

@elramen

@elramen elramen commented Oct 20, 2026

Copy link
Copy Markdown
Member

Make cogs measurements more granular by using the cogs future wrapper at a lower level in the call stack.

If we want even more granularization, and the ability to measure things that happen in the middle of a request's processing (i.e. nested cogs futures), we can do the following:

  • Use a thread-local pointing to the currently polling cogs-future's "tracker" (when a request's tokio task gets the thread, the top level cogs future sets the thread-local to point to its tracker).
  • The tracker stores total: cpu time elapsed in the request (as last recorded; only updated when a future finishes).
  • When a cogs future starts, it copies total into a local variable before.
  • When a cogs future polls, it increases its local cpu time: gross_local. It is gross because it includes nested futures.
  • When a cogs future finishes, it updates a map in the tracker that contains elapsed time per category, calculated by: category += gross_local - (total - before) where total - before make up nested cogs futures' elapsed time.
  • When a cogs future finishes, it also updates the tracker's total = before + gross_local.

This is a bigger change and it isn't prioritized atm, but something to keep in mind for the future in case we need it.

Fixes: https://linear.app/getsentry/issue/INGEST-1289

@elramen
elramen requested a review from a team as a code owner October 20, 2026 19:03
@elramen
elramen requested a review from loewenheim October 20, 2026 19:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant