The term you are looking for is likely "Confidential Informant." This refers to someone who provides information, often about criminal activity, to law enforcement or government agencies in exchange for some form of consideration, such as leniency in prosecution or financial compensation.
While "snitch" and "rat" can also refer to someone providing information, they are often used in more informal or derogatory contexts. "Spy" typically refers to someone gathering information covertly for intelligence purposes, potentially involving foreign governments.