Opentelemetry going to elastic APM but with environments depending on the ingress

We use environments to distinguish different projects and we have the problem to be able to ser the service.environment resource NOT in traefik ingress controller - since it serves all the cluster - but on the ingress routes or middlewares.
Is this possible?
These configurations should be not at ingress controller level but ad "ingress" level.
All the topic is independent from elastic APM since we send traced to an opentelemetry collector in the cluster and different deployments in different namespaces just configure resources differently at their level.