On-chip sampling of optical fields with attosecond resolution