We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Intent of each JobFilter hook?

This page provides some insight into how to use Job Filters, and what hooks are available, but I can’t really figure out the intended use of each one:

Using Job Filters

Some of them are a little more obvious, but I went browsing through the source code to get a concrete answer and ended up more confused. The StateMachine class seems to be where each filter gets called. As far as I can tell, there is no difference between OnStateUnapplied and OnStateApplied. Perhaps they are up to the developer to treat differently, but without documentation I’m not sure what sort of use cases are geared toward one or the other.

The real reason I ask is that I’m interested in logging performance stats off to a separate log location. I gather that I can pull the latency and duration from SucceededState at OnStateElection, but I’m also trying to gather latency and runtime information about failed jobs. I can’t determine the best one of these hooks to use for that purpose. Something like this schema would be nice to capture:

  • JobId: 1 | Method: PerformJob() | Latency: 1s | Duration 5s | Status: Success
  • JobId: 2 | Method: PerformJob() | Latency: 3s | Duration 2s | Status: Failed

Generally though, I’d be interested in knowing the intended use of each of the available hooks.

1 Like