Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(metrics): Fetch project config when metrics are received #2987

Merged
merged 7 commits into from
Jan 24, 2024

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Jan 23, 2024

Metrics that arrive through the global metrics endpoint do not currently trigger a refetch of the project config. If a single processing relay only receives metrics traffic (no envelopes) for a specific project, metrics might get stuck in the pre-aggregator a.k.a. metrics buffer.

ref: #2967.

@jjbayer jjbayer changed the title test(sessions): Metrics delivery fix(metrics): Fetch project config when metrics are received Jan 23, 2024

let project = self.get_or_create_project(message.project_key());
project.prefetch(project_cache, false);
project.merge_buckets(
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this change, the added integration test fails.

Comment on lines +714 to +716
// TODO: When the state is present but expired, we should send buckets
// to the metrics buffer instead. In practice, the project state should be
// refreshed at the time when the buckets emerge from the aggregator though.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should do this, but I'll leave it for a follow-up.

@jjbayer jjbayer marked this pull request as ready for review January 23, 2024 16:48
@jjbayer jjbayer requested a review from a team as a code owner January 23, 2024 16:48
{"buckets": {public_key: metrics}},
)

envelope = mini_sentry.captured_events.get(timeout=3)
Copy link
Member Author

Choose a reason for hiding this comment

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

This .get() fails without the prefetch.

message.buckets(),
);

let project = self.get_or_create_project(message.project_key());
Copy link
Member

@Dav1dde Dav1dde Jan 24, 2024

Choose a reason for hiding this comment

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

I wonder if we should just always prefetch in get_or_create_project. I found the same "bug" for metric metadata as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Dav1dde I would even go further and unify the multiple state enums we have for project configs at the moment:

  • GetOrFetch - either a cached project config or a channel
  • State - either a cached project config or a metrics buffer
  • ExpiryState - either Updated, Stale, or Expired

We might be able to make a single enum out of these, and give them an interface that makes it impossible to access a project without prefetching.

@jjbayer jjbayer merged commit 2e837ba into master Jan 24, 2024
20 checks passed
@jjbayer jjbayer deleted the test/session-delivery branch January 24, 2024 08:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants