-
Notifications
You must be signed in to change notification settings - Fork 3
Description
As a user of Netrics – either a "legacy" user or "new" – I expect the software to ship with a collection of built-in measurements (at least those available in the previous software). As such, existing measurement code, of potential use to us or to others, must be ported to the new Netrics framework.
This work is largely one of deletion rather than addition – measurements should be boiled down to their essential functionality, (without retry logic, etc.).
Under the Netrics framework, all measurements are simple executables.
Builtins will be installed with names prepended by netrics-, e.g. netrics-ping. This convention will make their purpose clear, have the effect of "bundling" them despite their separate existence, and these names will be given special treatment in configuration: (references to the measurement ping will imply the executable netrics-ping, and whether netrics-ping is a built-in or not).
However, builtins needn't be named this way in the codebase – (it is trivial to apply this convention upon installation) – within the codebase, ping is fine.
The "ideal" or most simple measurement is a standalone script: Python or otherwise. (It must handle its own execution via shebang, etc.). Installation will copy/link each built-in measurement script to the appropriate path and under the appropriate name.
That said, Python-based measurements are free to be more sophisticated than standalone scripts. (So long as there is a module with a single function to invoke without arguments – e.g. main() – then installation may trivially construct a script to invoke it.) This might allow our builtins to share code (to be "DRY"), etc. Such a package of built-in measurements might be contained within the netrics package (at src/netrics/measurement/builtin/ or otherwise). (How this looks remains to be seen and is up to the implementer.)
Upon execution, the measurement's contract with the framework is as follows:
- Upon execution/invocation, run the measurement! Just the measurement. No need for retries, etc. (If it's
ping, then runping.) If there's an exception, the return code should reflect this. - Result(s) to be persisted are printed to standard output (stdout) (the default for
print,echo, etc.) – presumably in JSON format, but the framework does not (at this point) care. - If you expect interesting measurement-specific configuration, we might set that in the framework's new measurements configuration file, but simply deliver it via standard input (stdin) – there's no need for the measurement executable to know where the framework configuration is or how it works ***.
*** (I'm really split on the best data format for this. JSON input and output make sense; and, if it's JSON then you'd just: json.load(sys.stdin). Obviously this is more natural if the main measurements config is itself JSON or YAML. But, I think TOML is friendlier than YAML for such files. Regardless, the framework can send the measurement config in whatever format, and even let it be configurable. To the framework code, there's nothing exceptional about reading TOML and writing JSON; though, to human beings involved on either end, it might be a little odd.)