Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Prepare to accept custom Collectors #46

Merged
merged 1 commit into from
Nov 11, 2021
Merged

Conversation

Earendil95
Copy link
Collaborator

@Earendil95 Earendil95 commented Apr 22, 2021

What is the purpose of this pull request?

From README.md:

N+1 problem is not a database specific: we can have N+1 Redis calls, N+1 HTTP external requests, etc.
We can make n_plus_one_control customizable to support these scenarios (technically, we need to make it possible to handle different payload in the event subscriber).

This PR is going to add an ability to create custom Collectors so we can track N+1 "everywhere, for everyone, forever" (c).

What changes did you make? (overview)

Is there anything you'd like reviewers to focus on?

Not yet. This PR currently makes it easier to track my progress.

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation

result = described_class.new(population: populate).call(&observable)

expect(result.size).to eq 2
expect(result.first[0]).to eq 2
expect(result.first[1].size).to eq 3
expect(result.first[1][:db].size).to eq 3
Copy link
Contributor

@mrzasa mrzasa May 4, 2021

Choose a reason for hiding this comment

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

Such a deep nesting may be a sign that it'd be better to return structs/objects instead of hashes. WDYT?

@Earendil95 Earendil95 force-pushed the extract-collector branch 2 times, most recently from 90d1459 to 97fedc2 Compare October 10, 2021 14:56
@Earendil95 Earendil95 marked this pull request as ready for review October 10, 2021 20:44
@Earendil95 Earendil95 changed the title [WIP] Prepare to accept custom Collectors Prepare to accept custom Collectors Oct 10, 2021
@palkan palkan changed the base branch from master to v1-dev November 11, 2021 18:33
Copy link
Owner

@palkan palkan left a comment

Choose a reason for hiding this comment

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

Finally, I found time to read through it carefully 🙂

Awesome work 👏

I've created a new branch — v1-dev — and suggest merging it right away into it. The core functionality has been implemented; now we need to do some cleanup.

Here is the list of thing I'd like to consider for the final v1 release:

  1. Naming.

The word "queries" is no longer reflecting the nature of the N+1 ... events? operations?
I think, we should use a more generic term internally as well as in matchers/assertions.

For backward compatibility, we can keep xxx_queries aliases.

  1. It would be great to make show_table_stats functionality generic as well. Say, show_tags_stats; DB table is a tag, URI hostname could be a tag, too.

  2. Backtraces should be a part of the Base collector; it's useful to have them for all collectors. "Query" truncation, too.

  3. Finally, abstractizing ActiveSupport Notifications away would be another move forward towards the bright Ruby (and not only Rails) future. We implement such idea in TestProf's EventProf; we can borrow an abstract interface from it.

@Earendil95 Earendil95 force-pushed the extract-collector branch 2 times, most recently from f747339 to 1fc25e5 Compare November 11, 2021 20:12
@Earendil95 Earendil95 merged commit 13b8f33 into v1-dev Nov 11, 2021
@Earendil95 Earendil95 deleted the extract-collector branch November 11, 2021 20:31
@Earendil95
Copy link
Collaborator Author

@palkan Thanks for the review! I've merged, as you suggested. Stay tuned, will post the other things soon someday :) Shall we create some issues out of the comment?

@palkan
Copy link
Owner

palkan commented Nov 15, 2021

Shall we create some issues out of the comment?

Not necessary; PRs are better ))

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.

3 participants