libdatadog
libdatadog copied to clipboard
Add Live debugging & Remote Configuration
Adding live debugging support. It requires remote configuration to work at all, so to do proper integration tests of the functionality, that part is also in this big PR.
Dynamic configuration is a small part, just 50 lines of code, describing the structures it contains.
As to more specific changes to current code:
- The sidecar is now per user (on windows it already uses the ConsoleSession), instead of per system.
- On Windows it was necessary as memory can only easily be shared within a ConsoleSession.
- On Linux it's now necessary as the notification mechanism for changes to the remote config are distributed via signals, which require either same euid or root-like capabilities.
- Note AsBytes in ddcommon currently requires
&'a AsBytes<'a>, while only&AsBytes<'a>(independent lifetime) is required.
General notes:
- Code in remote-config/ is meant to be reusable and also accessible via FFI as needed. For most users the bare
ConfigFetchershould be enough, and for some theSharedFetcheris needed. Fewest should actually need theMultiTargetFetcher. A FFi interface hasn't been defined yet as it wasn't needed:- ConfigFetcher in its simplest usage is just one function with two callbacks (store, update) essentially. StoredFile should be a wrapper for a type native to the FFI user (a pointer probably).
- SharedFetcher is similar, but presents a run-loop. To be used in anyway multi-threaded applications, now three callbacks: store, update and on_fetched.
- The sidecar will notify participating processes whenever remote config changes.
- The sidecar uses shared memory to transmit the stuff received by the remote-config stuff.
- live_debugger is:
- a lot of manual parsing logic (If some value is X, then these fields are applicable. If this field is present, then it means this, otherwise that etc.; things which aren't trivially described by just deserializing it into a struct).
- an evaluator for parsed expressions, i.e. walking the parsed AST and requesting values from the runtime.
- a log probe sender
TODOs:
- [ ] Windows support for notify on remote config change is still outstanding.
- [ ] There is an unused
timeoutinConfigFetcher. Drop it, or do we need it? No idea. - [x] Make used products configurable
- [ ] Figure out
ddtagssending for live debugger sender. - [ ] More /// docblocks on the sidecar side.
- [ ] Tests for
ConfigFetcher - [ ] Tests for
SharedFetcher - [ ] Tests for
MultiTargetFetcher - [ ] Tests for live debugger parsing.
- [ ] Tests for expr_eval.rs