-
Notifications
You must be signed in to change notification settings - Fork 4
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
Allow a callable object as the :patterns option of the Trace middleware #81
base: main
Are you sure you want to change the base?
Conversation
lib/orthoses/trace.rb
Outdated
@@ -7,14 +7,15 @@ class Trace | |||
autoload :Method, 'orthoses/trace/method' | |||
autoload :Targetable, 'orthoses/trace/targetable' | |||
|
|||
def initialize(loader, patterns:) | |||
def initialize(loader, patterns:, sort_union_types: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have added this option in the previous PR 🙇
@hibariya Thank you for contributing. The This PR looks to want to do more advanced class/module/method filtering. How about to use |
@ksss Sorry for the very late reaction 🙇 Got it, I'll try using |
Hi, @ksss 👋 I'd like to reopen this since I think we need something to improve the performance of this middleware. First, I tried Then I tried another approach: load all classes and modules defined under Since I believe that with the current Targetable implementation, there's not much room for optimization, to solve the problem above, I think there are a couple of ways:
What do you think? |
Forgot to reopen 🙏 |
@hibariya Thank you for the research.
|
Hi @ksss, sorry for the late reply. Yes, I'd like to generate RBS for existing apps.
Yes, as you mentioned, I don't think using the generated RBS as-is for type-checking is practical (at least at this point). That said, it's still useful for supplemental documentation purposes even today. Improving the middleware for this purpose does not always contradict the original design.
Good point. How about removing the TracePoint from the parameters and keep it the same as today ( |
Looks good! |
gotcha! |
098bcac
to
e1c5bff
Compare
e1c5bff
to
880f82e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
やられたいことが分からなくなったんですが、TracePointオブジェクトが使いたかったんじゃないんですか?
この使い方ならpatterns
で十分満たせるように思います。
私も書いててよくわからなくなっていました。上で背景含めてだらだら書いて長くなってしまっていたんですが、要は少し大きめのアプリケーションで走らせてみたら現実的な時間で終わらなかった (でも走らせたい) ので、 そういう動機を考えると、別途新しい option を導入するよりは、やはり |
I'd like to pass a Proc as the
patterns
option for the Trace middleware because I sometimes want to filter classes by a bit different conditions like filtering by the file path (TracePoint#path) rather than module name matching. This change allows users to pass an object that responds to:call
as the:patterns
option similar to Orthoses::RBSPrototypeRuntime.