-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add helpful remarks on custom DataCollector #7773
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
When creating my own data colletor, I was not clear on how to exactly collect my data (unrelated to request/response) Here are two remarks that would have helped me a lot by the time * collect is only called once to "pick-up, not "gather" * how/where to store and access data that is not related to request/response
Add helpful remarks on custom DataCollector
"make accessible to" instead of "for"
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 looks like a pretty nice addition. 👍 I just left two minor comments. If you would like to address them, that would be really nice. Otherwise, we can address them while merging.
profiler/data_collector.rst
Outdated
If the data that is not directly related to the request or response, you need to make the data accessible to your DataCollector. | ||
This can be achieved by injecting the service into your DataCollector. | ||
|
||
|
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.
one blank line is enough here
profiler/data_collector.rst
Outdated
@@ -73,6 +78,12 @@ The getters are added to give the template access to the collected information. | |||
|
|||
.. caution:: | |||
|
|||
If the data that is not directly related to the request or response, you need to make the data accessible to your DataCollector. | |||
This can be achieved by injecting the service into your DataCollector. |
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 think we can be a bit more specific what we mean with "the service" (something like "by injecting a service that provides this information into your data collector).
@@ -73,6 +78,11 @@ The getters are added to give the template access to the collected information. | |||
|
|||
.. caution:: | |||
|
|||
If the data that is not directly related to the request or response, you need to make the data accessible to your DataCollector. | |||
This can be achieved by injecting the service that holds the information you intend to profile into your DataCollector. |
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.
Would a code example (CustomService in constructor, gathering data in the collect method) be helpful here? Or would you consider it to be too specific?
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 think that's a bit too specific. But let's see what other members of the @symfony/team-symfony-docs team think about it.
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 don't think this is needed, this note sounds clear enough, also a constructor is not this only way to inject data.
Note that the collector itself can be used as listener in order to grab anything, and then collect data using it, both injection and observation are used in the core btw.
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.
Good point. Then why not put this into the doc as a note as well?
I think this is clear once you are familiar with the concepts of Symfony but not for the n00b reading this for the first time
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 don't think a code example would improve anything here. At the point you're creating your own DataCollector, you're probably already aware of injection and DI. The comment is a nice addition as it is right now imo. In case people get stuck here, there's always IRC or Slack, where they will probably be forwarded to the DIC docs.
Thank you @xosofox. |
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #7773). Discussion ---------- Add helpful remarks on custom DataCollector When creating my own data colletor, I was not clear on how to exactly collect my data (unrelated to request/response) Here are two remarks that would have helped me a lot by the time * collect is only called once to "pick-up, not "gather" * how/where to store and access data that is not related to request/response Commits ------- 29522b3 Add helpful remarks on custom DataCollector
* 2.7: (21 commits) Update optional_dependencies.rst Fix xml blocks [#7875] minor tweaks Minor fix Minor changes [#7773] fix line length Add helpful remarks on custom DataCollector Remove use of deprecated security.exception_listener.class parameter Update resources.rst Fix incoherent ut8mb4 collation in Doctrine setup Fix decorating service definition fix empty XML element [#7873] add missing toctree entries Reworded the introduction of the contributing docs [HttpFoundation] Fix clearstatcache first arg Explain how to provide a stack trace Add link to the Slack support channel Mentioned FOSRestBundle's content negotiation Used the article example consistently in the example Update formats.rst ...
* 2.8: (24 commits) Update optional_dependencies.rst Fix xml blocks pass only strings to loadUserByUsername() Fix Authenticator Class (getCredentials) example Added the picture that shows how GuardAuthenticationListener calls Authentication Guard methods. [#7875] minor tweaks Minor fix Minor changes [#7773] fix line length Add helpful remarks on custom DataCollector Remove use of deprecated security.exception_listener.class parameter Update resources.rst Fix incoherent ut8mb4 collation in Doctrine setup Fix decorating service definition fix empty XML element [#7873] add missing toctree entries Reworded the introduction of the contributing docs [HttpFoundation] Fix clearstatcache first arg Explain how to provide a stack trace Add link to the Slack support channel ...
* origin/2.7: (51 commits) Avoid backticks in shell scripts Update optional_dependencies.rst Fix xml blocks [#7875] minor tweaks Minor fix Minor changes [#7773] fix line length Add helpful remarks on custom DataCollector Remove use of deprecated security.exception_listener.class parameter Update resources.rst Fix incoherent ut8mb4 collation in Doctrine setup Fix decorating service definition fix empty XML element [#7873] add missing toctree entries Reworded the introduction of the contributing docs [#7844] add XML and PHP config examples Property access [HttpFoundation] Fix clearstatcache first arg Explain how to provide a stack trace fix remaining setDefinition() call ...
* 3.2: (39 commits) updating instance Avoid backticks in shell scripts Update optional_dependencies.rst Fix xml blocks pass only strings to loadUserByUsername() Fix Authenticator Class (getCredentials) example Documented addAnnotatedClassesToCompile() and the use of class patterns Added the picture that shows how GuardAuthenticationListener calls Authentication Guard methods. [#7205] minor tweak Simplified the use of transChoice() [#7875] minor tweaks Minor fix Minor changes Properly show all events and describe guard events [#7891] remove not needed sentence [#7773] fix line length Add helpful remarks on custom DataCollector Remove use of deprecated security.exception_listener.class parameter Update resources.rst Fix incoherent ut8mb4 collation in Doctrine setup ...
* 3.4: (40 commits) Adding an article to explain the 3.3 changes, and how to upgrade updating instance Avoid backticks in shell scripts Update optional_dependencies.rst Fix xml blocks pass only strings to loadUserByUsername() Fix Authenticator Class (getCredentials) example Documented addAnnotatedClassesToCompile() and the use of class patterns Added the picture that shows how GuardAuthenticationListener calls Authentication Guard methods. [#7205] minor tweak Simplified the use of transChoice() [#7875] minor tweaks Minor fix Minor changes Properly show all events and describe guard events [#7891] remove not needed sentence [#7773] fix line length Add helpful remarks on custom DataCollector Remove use of deprecated security.exception_listener.class parameter Update resources.rst ...
When creating my own data colletor, I was not clear on how to exactly collect my data (unrelated to request/response)
Here are two remarks that would have helped me a lot by the time