However, there are at least two problems with this kind of simple periodic sampling approach. First, if the sampling period is too long then you may miss important data points such that you do not see transient spikes or droops in the container level (i.e. because the spike or droop comes and goes within a sampling period. And second, if the sampling period is very short, you will have the problem of collecting too many samples. The second problem can be mitigated by testing whether new level samples are different than the last recorded sample before recording the new sample, but this adds to the complexity of the sampling code.
So the advantage of hooking a trace function as described in the monitoring guide is that you can just record all of the container's level transitions; you get each transition with the exact simulation time the transition occurs without any extraneous data points.
Cheers,
Pete