For our expirence using anything relate to monitoring with Elastic APM, you can use one variable availiable into each APM agent like RUM JS, Java, .NET, NodeJS, etc. Check this below links:
For RUM JS check this URL: Configuration | APM Real User Monitoring JavaScript Agent Reference [master] | Elastic
For .NET check this URL: Core configuration options | APM .NET Agent Reference [1.11] | Elastic
Using that variable "Environment" since each APM Agent you can set from which environment are sending information like Production, Staging, QA, Testing, Development or other value whatever you want to use.
I hope this can help you and reply if you need more information.