appscope
appscope copied to clipboard
When multiple processes write to an event/metric file, that file can become corrupted easily
We have seen this when scoping applications like apt, that create multiple child processes. The events.json, metrics.json files can become mangled.
In a container:
apt update
scope run -- apt install -y python3 nginx firefox
scope events -a
There are are a number of possible approaches here:
- Do nothing. Suggest that using the cli to write to files is not ideal because of the issue described here, and that the workaround is to use tcp or unix destinations instead.
- Switch the CLI to configure scoped processes to sent their data to the cli over tcp or unix transports. Then the cli can write received data to a file in a way that prevents corruption.
- Use SCOPE_PID to configure the library to write to files with pid-specific names. The cli would need to be improved to look for an arbitrary number of files with this approach.
3 looks like the easiest and most robust approach. We would need to modify the CLI to read in multiple event and metric files relating to one session. Tagging this as a CLI task.