I am trying to give value to a certain package and library by building some usage stats. This package is written in python and invoked/imported by users on remote machines/cluster
What we are trying to do is to set up a certain tracking mechanism that will register or log every time someone imports the package and ideally how long he used it.
I can think of a a normal logger that will log at import time of the package and will log when the process closes/dies/exits using atexit function.
# let's import the package here import package # at this stage the package automaticaly logs something like the following in a certain file # os.getpid() | getpass.getuser() | os.uname() | importing package time.time() # when the process or session is closed. ataxit will execute the same function that will log the following # os.getpid() | getpass.getuser() | os.uname() | ataxit process time.time()
This way this log file can be analyzed later for info about package usage.
Now, I wonder if there is another more elegant or standard solution to do all of that.