Filter transactions on basis of request header or MDC

I have a usecase where I would like to segregate my requests on the basis of a value present in a particular header, let's say 'X'. X would be set only to true/false. I would like transaction count, latency, errors all segregated. Is it possible in Elastic APM Java agent?

I read about Filters but couldn't understand how I can use it in my case.

Or is it possible to do it by attaching two elastic APM Java agents somehow?

You can't attach 2 Elastic APM agents to one JVM. When you say requests and headers, I presume you mean http requests and headers. We don't have any mechanism to configure the Java agent to do what you want. You can possibly do it yourself using the public APIs.