-
Notifications
You must be signed in to change notification settings - Fork 50
Display discovered clients in the profiler #154
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
Conversation
I think it is fair to share plugins. The plugins should generally be stateless.. But the StackPlugin is special. Can it be treated in a special way o should we try to make it stateless? |
StackPlugin is already managed in a special way (i.e. not decorated with PluginClient). I think we have to work on how plugins are decorated. If the plugin is a shared one, we have to register it once and decorate only once. If the plugin is defined in the client, from httplug catalogue (means stopwatch, redirect), we have to create an instance per client and decorate this instance. What we can do for user created plugins? Shall we consider them like shared plugins and document that sharing a plugin not designed for can be harmful? In the current definition, I would make all plugins from And then we add a StackPlugin as first plugin. WDYT? |
Good
Yes.
That is a BC break, right? Why don't we use the same logic for user defined plugins as we do with ours? |
I will share again the stopwatch plugin and only focus this PR on fixing #133. |
$pluginServiceId = $serviceId.'.plugin.'.$pluginName; | ||
|
||
$definition = class_exists(ChildDefinition::class) | ||
? new ChildDefinition('httplug.plugin'.'.'.$pluginName) |
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.
There too many concats here.
ChildDefinition('httplug.plugin.'.$plug...
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.
Same on the next line
Im testing this PR. The auto_discovered_client does not show up the the profiler. |
Finally I focused this PR about displaying auto discovered clients in the profiler and fixing #133. |
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.
Excellent. I've tested the code and it works flawlessly.
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.
great work, thanks!
we can merge as is, or we can do our future selves a favor and add a line to each method to explain what it does (beyond what the method name says - some of the methods do have such one-liners and i find them helpful)
|
||
/** | ||
* @param ContainerBuilder $container | ||
* @param $pluginServiceId |
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.
missing typehint
* @param string $pluginName | ||
* @param array $pluginConfig | ||
* | ||
* @return string |
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.
please add something like "service id for this plugin"
Thanks for your review. I will add some description to extracted methods. |
I fixed issues pointed out by @dbu. I also added one line description for new methods. Proofreading is welcome! |
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.
thanks! i went over the docs and commented where i am still confused. but we can totally merge as is, its quite some improvement in here! the comments that are left basically are things that are now more visible that i find confusing in the existing code already.
if you want to improve the phpdoc some more, please do but otherwise feel free to squash and merge.
->getDefinition('httplug.collector.plugin_journal') | ||
->addMethodCall('setPlugins', [$name, ['httplug.plugin.stopwatch']]) | ||
; | ||
// Add the newstack plugin |
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.
new stack plugin? or newstack? if i guess correctly what we do here, lets do: // To profile requests, we put a stack plugin instance as first plugin in the chain, followed by the stopwatch plugin
*/ | ||
private function configureNewStackPlugin(ContainerBuilder $container, $clientName, $serviceId) | ||
{ | ||
$pluginServiceId = $serviceId.'.plugin.newstack'; |
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 see that this is a refactoring and you just kept the previous name, but why do we call it "newstack"? its kind of confusing to me. its not really more new than other services, just specific to this httplug client, right?
* | ||
* @param ContainerBuilder $container | ||
* @param string $clientName | ||
* @param string $serviceId |
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.
is this the service id of a httplug client? if so, lets say that.
* Configure a new StackPlugin for a client. | ||
* | ||
* @param ContainerBuilder $container | ||
* @param string $clientName |
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.
this is used to configure the stack plugin so that we can show the right client name in the profiler, right? maybe mention this here...
@dbu I improved comments. Hope this is now easier to understand. |
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.
LGTM
Content
Auto discovered clients were not visible in the profiler. This behavior is broken since at least 1.3. I didn't test any further back to find when it was broken.
This also fixes the root cause of #133. The easier way to test it is with
knplabs/github-api
.The bug root cause was caused by the stopwatch plugin which was shared between every clients. When a client was configured, the stopwatch plugin gets decorated with the
ProfilePlugin
and when executed, no stack plugin was executed before.About plugins state
So we have a plugin instance per client. I don't know if it's a good or a bad thing but we probably have to be clear on what to do. I think its ok to share a plugin if it is stateless, but if the plugin is stateful it should not be shared at all (like the StackPlugin which hold the client name).
I think we should choose a way to go, shared plugins or no shared plugins. Doing the choice will probably allow us to do some refactoring in the bundle container extension, which looks like really complicated to met.
Ping @Nyholm @sagikazarmark @dbu