Tracks a given operation.
Works also with unsafe operations that throw exceptions, as the tracking gets stopped. The exceptions are not swallowed though.
function to track