Allow a callable object as the :patterns option of the Trace middleware - #81
Allow a callable object as the :patterns option of the Trace middleware#81hibariya wants to merge 4 commits into
Conversation
| autoload :Targetable, 'orthoses/trace/targetable' | ||
|
|
||
| def initialize(loader, patterns:) | ||
| def initialize(loader, patterns:, sort_union_types: true) |
There was a problem hiding this comment.
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
ksss
left a comment
There was a problem hiding this comment.
やられたいことが分からなくなったんですが、TracePointオブジェクトが使いたかったんじゃないんですか?
この使い方ならpatternsで十分満たせるように思います。
|
私も書いててよくわからなくなっていました。上で背景含めてだらだら書いて長くなってしまっていたんですが、要は少し大きめのアプリケーションで走らせてみたら現実的な時間で終わらなかった (でも走らせたい) ので、 そういう動機を考えると、別途新しい option を導入するよりは、やはり |
I'd like to pass a Proc as the
patternsoption 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:callas the:patternsoption similar to Orthoses::RBSPrototypeRuntime.