Skip to content
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

[RFC] add HydrationFactory as extension point for tracking hydrations #9545

Open
wants to merge 1 commit into
base: 3.4.x
Choose a base branch
from

Conversation

kbond
Copy link
Contributor

@kbond kbond commented Feb 25, 2022

This is a proposed extension point to help solve doctrine/DoctrineBundle#109. I'm thinking a HydratorInterface that AbstractHydrator implements should be added but wanted to get some feedback/input before going further.

The doctrine bundle could use this to add hydration times to the timeline:
Symfony-Profiler

The doctrine bundle could add something similar to https://github.com/debesha/DoctrineProfileExtraBundle#screenshots to the profiler panel.

You can see an example of how this could be used in DoctrineBundle here: https://github.com/kbond/symfony-reproducer/tree/hydration-profiler-poc (specifically kbond/symfony-reproducer@9a4e91b).

I don't think this causes any performance problems for hydration (when using the DefaultHydratorFactory).

@kbond kbond force-pushed the hydrator-factory branch 3 times, most recently from ceb80da to b4e3f3a Compare February 25, 2022 16:39
@beberlei
Copy link
Member

I am torn, because it will encourage people to overwrite the existing hydrators, which are a bit too complex. Besides tracking the time there are not really many other use cases to use this extension point.

@kbond
Copy link
Contributor Author

kbond commented Feb 25, 2022

Any other ideas how to achieve? I really think this is an important metric to make available.

Maybe a HydrationLogger - similar to CacheLogger? Maybe a HydrationEvent?

@ostrolucky
Copy link
Member

I would be fine with this. This solves one of the inconsistencies between ODM and ORM, as ODM has this option. And I'm not a fan of not having features just because you can abuse them. I think ORM learned this lesson as well, since multiple important features have been deprecated years ago, only to get comeback recently and de-deprecated.

@kbond kbond changed the base branch from 2.12.x to 3.4.x October 21, 2024 01:32
@kbond
Copy link
Contributor Author

kbond commented Oct 21, 2024

Rebased to 3.4 with the hope of continuing this discussion 😄 🙏🏻

Copy link
Contributor

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions bot added the Stale label Jan 24, 2025
@ostrolucky
Copy link
Member

This seems pretty simple and straightforward. Anything against merging it (after rebase and changing target branch ofc) @greg0ire ?

@greg0ire
Copy link
Member

greg0ire commented Jan 24, 2025

I think we should take @beberlei 's concern into account. A HydrationLogger sounds good, although let's maybe not use a name that locks down too much what this is supposed to be used for. Maybe a name that includes "instrumentation", in reference to https://martinfowler.com/articles/domain-oriented-observability.html ?

@ostrolucky
Copy link
Member

I don't see how adding some instrumentation hydrator would work, since this hydrator needs to wrap all the other hydrators and needs to be flexible so that bundle can execute custom logic before/after hydration. It's not even clear how would user collect the hydration result if it's in some object they don't instantiate and don't normally have access to.

@kbond
Copy link
Contributor Author

kbond commented Jan 24, 2025

Maybe a HydrationLogger

I did not have a clear idea here and honestly, I feel like this would add overhead we don't want.

@github-actions github-actions bot removed the Stale label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants