Documentary film making is more journalism than entertainment and, for this reason, a documentary film maker can usually avoid prosecution for "reporting" on drug use or prostitution or gang wars and so on, even when the filming shows illegal acts.
The film maker may not, however, escape being asked to reveal names and locations, and he may be asked to testify at a criminal or civil trial. The film maker may be subpoenaed and asked to produce material gathered during the course of the filming. Most journalists will resist such efforts, and shield laws give some protection against testifying.
The best way to handle the filming of individuals is to obtain releases after filming, and make no promises about confidentiality. Your "actors" can be in trouble for committing illegal acts. That is why identities are often disguised in news stories. Careful editing of a film can allow some anonymity.
As a documentary film maker, you must be aware of your rights in filming and the rights of those you film. Lawsuits can arise from defamatory content and invasion of privacy. Truth would be an absolute defense against defamation, and courts usually protect the press (and again, when filming a documentary you are more journalist than entertainer) against invasion of privacy suits when covering stories of legitimate public interest - but there are exceptions.
If you are filming friends shooting heroin or snorting coke for a YouTube video, however, you will probably lose most, if not all, of the protection a documentary film maker or journalist has, and you and your friends could all be in trouble.
Zigner had the best advice - consult with an entertainment lawyer. The lawyer can help you avoid the legal pitfalls you may face in your film.