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

newrelicTransactionName property in serialized message #3

Open
Lharz opened this issue Feb 15, 2021 · 3 comments
Open

newrelicTransactionName property in serialized message #3

Lharz opened this issue Feb 15, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Lharz
Copy link

Lharz commented Feb 15, 2021

Hi,

I've been using your bundle and used the NameableNewrelicTransactionInterface to customize the transaction names in NewRelic dashboard, for my different message classes. Now, when I'm using the symfony/serializer I have a newrelicTransactionName property that is added to the stringified messag, which is unintended I think.

A quick fix that I found is to add a serialization configuration to my app like this one :

# config/serialization/packages/NameableNewrelicTransactionInterface.yaml
Arxus\NewrelicMessengerBundle\Newrelic\NameableNewrelicTransactionInterface:
    attributes:
        newrelicTransactionName:
            ignore: true

But I think it would be better to let the bundle itself handle it, with a configurable option for example.

Let me know what you think.

Cheers !

@janvernieuwe
Copy link
Member

Hi @Lharz !

Thanks for noticing this and suggesting a fix, I'll take a look at it as soon as I can find the time.
A PR is always welcome of course!

@janvernieuwe janvernieuwe added the enhancement New feature or request label Feb 16, 2021
@Lharz
Copy link
Author

Lharz commented Feb 16, 2021

Sure, I'll make one if I can find the time too.

@CRC-Mismatch
Copy link

CRC-Mismatch commented May 7, 2024

This is a side-effect of altering the entity/message class to implement a "getter" for the transaction name. For all that Symfony Serializer knows, it's a "real" property, since it looks for public properties and methods prefixed with get, is, has when normalizing.

This also creates another side-effect of failing to deserialize the message if there's no public property, or public setter for newrelicTransactionName (e. g. if the getNewrelicTransactionName method is implemented as returning a constant/literal string with no public property backing it or no setNewrelicTransactionName counterpart).

If using the current interface approach is ideal, I guess the "right" solution would be to include a decorator for the Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory service that automatically ignores the getNewrelicTransactionName method (and/or newrelicTransactionName property) for classes that implement NameableNewrelicTransactionInterface, injected through https://github.com/ArxusPublic/messenger-newrelic/blob/master/Resources/config/services.yaml

Otherwise, I'd suggest keeping the metadata completely isolated from the message data by using stamps, as proposed in #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants