0

I would like to be able to build up a log of user activities, capturing data such as who they were, where they logged in from, what activity did they take, and what data did they change (both before and after).

Most of the user-related data can easily be picked up by middleware running on my web server, that can hook into the HTTP context for every request, and based upon some rules I define, it can publish an event to an event stream. However, while it can tell me what new values were set (based on the request body), it cannot tell me what the old data values were, at least not without integrating it down to the database layer.

Conversely, I can easily find out what old values and new values are by writing code at the database level (e.g. with triggers or CDC), and then publishing those as data events to the event stream, but that approach doesn't have access to all the user HTTP metadata.

I could potentially combine the two approaches, using a correlation identifier to match up the HTTP and the SQL events, but it doesn't feel like a decent solution. I'm trying to avoid any approach that requires the developer to have to write explicit logging code somewhere in the business layer to capture all the data.

3
  • There is a "pattern" on this site: people ask broadly for patterns for a topic (often called "shopping for patterns"), and then they are astonished they question gets closed as it "needs more focus" (this question already got one, probably from gnat, who never revokes his votes anymore). Honestly, I think this can be avoided here by some rewording, let me fix this for your.
    – Doc Brown
    Commented Mar 8 at 6:38
  • "I could potentially combine the two approaches, using a correlation identifier to match up the HTTP and the SQL events, but it doesn't feel like a decent solution." Very curious to learn about what makes a solution decent.
    – rwong
    Commented Mar 8 at 13:29
  • 1
    @rwong something with as few moving parts as possible, basically. If I'm having to pull information from multiple sources, then aggregate etc, there's a lot of scope for things to go wrong and big chunks of useful information get lost. Commented Apr 2 at 23:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.