zendesk / maxwell

Maxwell's daemon, a mysql-to-json kafka producer
https://maxwells-daemon.io/
Other
4.01k stars 1.01k forks source link

User sessions #2065

Closed colinmollenhour closed 10 months ago

colinmollenhour commented 10 months ago

Is it possible to somehow capture a user_id from one update and attach that to records that don't have a user_id column but that occurred from the same transaction or thread?

For example, if the client ran this:

UPDATE users SET last_activity = NOW() WHERE user_id = 5;
BEGIN TRANSACTION;
INSERT INTO events (`message`) VALUES ('asd');
COMMIT;

I'd like to know the user_id responsible for the insert event which is known because the same thread did an update on the PK of the users table with the user_id. This makes the assumption that the client is using one thread per user which I think is a safe assumption to make with a common PHP app, right?

I want to do this with dozens of tables and with updates so not just inserts, so I don't think simply adding a user_id column to every table just for this purpose is a good solution.

Is this already possible with Maxwell? Perhaps related to #2064 ?