A middleware for data collection