Repository navigation
Add hydrator decorators and a tracing extension - #213
Closed
DavidBadura wants to merge 4 commits into
Closed
DavidBadura wants to merge 4 commits into
DavidBadura wants to merge 4 commits into
Conversation
Extensions can now register decorators on the builder which wrap the built hydrator. They are applied by the new buildHydrator() method, build() is deprecated since it can only return the plain StackHydrator. The TracingExtension is the first decorator: it passes every hydrate and extract call to a Tracer, a StopwatchTracer for the Symfony Stopwatch is included.
build() can only return the plain StackHydrator, so silently dropping the decorators would hide that e.g. tracing is not active. It now throws a DecoratorsNotApplied exception pointing to buildHydrator().
|
Hello 👋 here is the most recent benchmark result:
This comment gets update everytime a new commit comes in! |
The StackHydrator injected itself into the hydrator aware normalizers, so nested objects bypassed all decorators and were e.g. not traced. buildHydrator() now sets the outermost hydrator as root hydrator on the stack, which is then passed to the normalizers instead.
This way the tracing is wrapped around decorators with the default priority and also measures them.
DanielBadura
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extensions can now wrap the built hydrator with a
HydratorDecorator, registered viaStackHydratorBuilder::addDecorator()with a priority like middlewares. Decorators are applied by the newbuildHydrator(): Hydrator.build()is deprecated because itsStackHydratorreturn type can't carry decorators, and it throws aDecoratorsNotAppliedexception if decorators are registered instead of silently dropping them. In 3.0 the builder can be renamed andbuild()return the decorated hydrator.The decorated hydrator is also set as root hydrator on the
StackHydrator, which passes it to the hydrator aware normalizers instead of itself. That way nested objects go through the decorators as well.The first user is a new
TracingExtension. It passes everyhydrateandextractcall to aTracer, and aStopwatchTracerfor the Symfony Stopwatch ships with it (symfony/stopwatchis only suggested). Nested objects are traced too, inside the trace of their parent.This is also the groundwork for the generated middleware branch, which can then register its fast path as a decorator instead of replacing the hydrator.