Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

xosofox
Copy link
Contributor

@xosofox xosofox commented Apr 8, 2017

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

xosofox added 2 commits April 8, 2017 13:29
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"
Copy link
Member

@xabbuh xabbuh left a 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.

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.


Copy link
Member

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

@@ -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.
Copy link
Member

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).

@HeahDude HeahDude added this to the 2.7 milestone Apr 12, 2017
@@ -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.
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

@xabbuh
Copy link
Member

xabbuh commented May 17, 2017

Thank you @xosofox.

xabbuh added a commit that referenced this pull request May 17, 2017
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
xabbuh added a commit that referenced this pull request May 17, 2017
@xabbuh xabbuh closed this May 17, 2017
xabbuh added a commit that referenced this pull request May 18, 2017
* 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
  ...
xabbuh added a commit that referenced this pull request May 18, 2017
* 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
  ...
weaverryan added a commit that referenced this pull request May 20, 2017
* 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
  ...
weaverryan added a commit that referenced this pull request May 20, 2017
* 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
  ...
weaverryan added a commit that referenced this pull request May 20, 2017
* 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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants