tevent: add API to trace events and requests

This is a continuation of !1810 (closed)

The chain id implementation was moved to SSSD side, but we need to be able to hook into three places:

  • event creation
  • before handler
  • after handler

The "after handler" can be mitigated by using an existing trace api "TEVENT_TRACE_AFTER_LOOP_ONCE". This, however, is not enough for requests since the handler can be executed synchronously when tevent_req_done is called and therefore it does not return to the event loop but it returns to the function which called tevent_req_done. We need to make sure to reset the ID to the prior value in this case. Therefore a handler wrapper was introduced to cover this case.

I took inspiration in the existing trace API and tried to mimic it. I hope this is something you are willing to accept.

This works for us in most cases and we can workaround the cases where it fails. Ideally, we need to set a global tevent request trace callback/wrapper instead of trying to inherit it when available to also cover cases that are not related to any incoming request and thus have the tag 0, but in this case they also don't have the callbacks set. This requires a global variable against since the request does not always have access to the event context, please let me know if such usage of global variable would be accepted.

@metze @vlendec Please let me know if this version is acceptable.

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • (optional) This MR is just one part towards a larger feature.
  • (optional, if backport required) Bugzilla bug filed and BUG: tag added
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated
  • CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)

Reviewer's checklist:

  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code
Edited by Pavel Březina

Merge request reports

Loading