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

Allow to pass custom serializer and representation_serializer in configuration #491

Conversation

olsavmic
Copy link

@olsavmic olsavmic commented Apr 28, 2021

Resolves #482

Well I can improve the docs but I would say that such compiler pass is rather a hack than proper solution.
The problem with the compiler pass is that it's a modification of the internals and not the public API so it's a subject to change in future releases without any warning.
I know of SerializableInterface and class_serializers but there are use cases when you need to modify "global" behaviour.
I'd prefer to add the representation serializer (and perhaps even the serializer) as optional configuration options.
I can prepare a PR if such modification is a welcome change.

@olsavmic
Copy link
Author

Custom serializer can then be registered as a service as usually

App\Logger\SentryReprSerializer:
    arguments:
        $options: '@sentry.client.options'

@olsavmic olsavmic force-pushed the allow-custom-serializer-configuration branch from 82110a6 to 4b19792 Compare May 6, 2021 14:18
@olsavmic
Copy link
Author

@Jean85 @ste93cry I did not receive any comment on this issue. Can I ask for a review of this PR or a comment on the related issue so we can proceed or close the issue?

Thanks a lot!

@Jean85 Jean85 added this to the 4.2 milestone May 14, 2021
Copy link
Collaborator

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine for what I can see. It would require a changelog entry though.
Also, I'll retarget do develop since it's a new feature.

@ste93cry WDYT? Is this a valuable feature in your opinion?

@Jean85 Jean85 changed the base branch from master to develop May 14, 2021 12:58
@olsavmic olsavmic force-pushed the allow-custom-serializer-configuration branch 2 times, most recently from b9b630d to a9aa287 Compare May 14, 2021 15:43
Copy link
Collaborator

@ste93cry ste93cry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a valuable feature in your opinion?

Yes, it is. In the future though I would like to see both serializers gone and replaced with either a refactored version or a third party lib so that we don't have to maintain the mess they are right now

src/DependencyInjection/SentryExtension.php Show resolved Hide resolved
src/DependencyInjection/SentryExtension.php Show resolved Hide resolved
tests/DependencyInjection/SentryExtensionTest.php Outdated Show resolved Hide resolved
tests/DependencyInjection/SentryExtensionTest.php Outdated Show resolved Hide resolved
tests/DependencyInjection/SentryExtensionTest.php Outdated Show resolved Hide resolved
tests/DependencyInjection/SentryExtensionTest.php Outdated Show resolved Hide resolved
…guration

- Add options

- Add changelog

- CR fix
@olsavmic olsavmic force-pushed the allow-custom-serializer-configuration branch from a9aa287 to e0b7f63 Compare May 20, 2021 15:31
@olsavmic olsavmic requested review from ste93cry and Jean85 May 20, 2021 15:32
@ste93cry
Copy link
Collaborator

Stricly speaking about the current PR's code I have nothing more to say besides great work, however I'm now wondering if this is the best way to tackle this problem. The fact is that the serializer requires the options of the client whose service is not defined until it gets created by the SentryExtension during the compilation phase of the container. In turn, when I coded the service of the options I made it private because my though was (and is) that to access them you should pass from the client: the options is not something meant to be injected as a normal service because it belongs to a specific client instance. Maybe, instead of allowing to set the serializer instance, we should instead use a factory that given the options returns an instance of the serializer, forcibly making people aware that each client must have its own serializer instance (which usually doesn't happen)?

@github-actions
Copy link

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

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.

Custom RepresentationSerializer
3 participants