Open abccbaandy opened 2 weeks ago
Thanks for the suggestion. Do you really mean to add custom info and not to overwrite the app
value?
I would like to know first the use case and how you intend to provide those informations. Although it is technical possible to provide this information (at least my assumption after having a glance), I don't know yet why this might be useful.
The only place where you can see this is the query log on the server side. Also, please keep in mind that this can only be achieved via some kind of callback to a transaction manager metadata source that would get invoked for every transaction.
Thanks for quick reply.
My use case is : Audit log via Change data capture (CDC). I want put some user metadata there, so I can track who did the change/where the change happen. For the user metadata, field will have user ip, user name, user client app version...etc, those will get from request header/body in our api. I think this part will be fine if the metadata implement allow us to access spring bean.
Do you really mean to add custom info and not to overwrite the app value?
About add or overwrite, I think we are fine with some spring way via a provider interface with a default impl to let user to choose if they want overwrite the metadata totally or just add some custom info.
This makes sense. But I want to add that overriding the app
fields will be something that we don't want to enable.
It's important for us to keep this the way it is. Mostly because we see customers/users approaching us with their problems/questions and we need those information to be present. Even if we would warn them, they would change it nevertheless and than we are missing important bits.
I get it, we want add those metadata for the same reason.
But I have to say, as a lib/framework, there is no way to prevent the developer to do anything.
I can call tx.setMetaData
to override the app field without any issue.
Anyways, you can provide a way to add
metadata only, it can prevent misuse this feature.
But for this you would need to get a handle on the transaction object that is currently in use by the Spring transaction. Which is by far less convenient than having a supplier that allows the overwrite of the app field. Just want to ensure that there is no way this might happen accidentally.
Ya, this is why I open this issue.
Hope we can have a convenient and reliable way to ADD
metadata soon :)
Now it's hard code the
UserAgent
only https://github.com/spring-projects/spring-data-neo4j/blob/1549e95760852f1b0bd17ef770767f8a24c19cd4/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtils.java#L116It will be more useful have some convent way to add custom info.