# Setting Environment for Traces Collected by OpenTelemetry Collector

**URL:** <https://discuss.elastic.co/t/setting-environment-for-traces-collected-by-opentelemetry-collector/304160>\
**Category:** APM\
**Tags:** open-telemetry\
**Created:** [May 7, 2022, 1:50am UTC](https://discuss.elastic.co/t/setting-environment-for-traces-collected-by-opentelemetry-collector/304160 "2022-05-07T01:50:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Knecht](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hans_knecht/32/103109_2.png) [@Hans\_Knecht](https://discuss.elastic.co/u/Hans_Knecht)\
**Post date:** [May 7, 2022, 1:50am UTC](https://discuss.elastic.co/t/setting-environment-for-traces-collected-by-opentelemetry-collector/304160/1 "2022-05-07T01:50:53Z")

</div>

**Kibana version** : 7.17.2

**Elasticsearch version** : 7.17.2

**APM Server version** : 7.17.2

**APM Agent language and version** : Open Telemetry Collector

**Browser version** : N/A

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: ECK

**Fresh install or upgraded from other version?** N/A

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

- Runs in K8s, but not super relevant

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

Using the Open Telemetry Collector (For traces generated by something like istio) use the attributes processor to upsert a service.environment attribute. The APM server will map that to labels.service\_environment, rather than service.environment.

Not sure how get service.environment, especially in light of: [Set default `service.environment` · Issue #4468 · elastic/apm-server · GitHub](https://github.com/elastic/apm-server/issues/4468) which is going to remove the undefined environment option.

**Steps to reproduce** :  
1.  
2.  
3.

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![piotrkula](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piotrkula/32/106129_2.png) [@piotrkula](https://discuss.elastic.co/u/piotrkula)\
**Post date:** [May 25, 2022, 9:15am UTC](https://discuss.elastic.co/t/setting-environment-for-traces-collected-by-opentelemetry-collector/304160/2 "2022-05-25T09:15:30Z")

</div>

In DotNet I had to specifically add attributes on the Resource builder.

With out those values the Metrics or Traces dashboards functionality is limited.

I don't know how exactly you do this for your situation but I hope its a direction that can help you solve it

- deploymnet.environmnet actually gets transformed to to service.environment (in the Exporter code for DotNet) - I didn't have time to change it to the OTLP standard name as you suggested

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/5/957cc840358ba2572a883dcba16822bd73771091.png)

---

<div class="post-metadata">

**Author:** ![Hans\_Knecht](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hans_knecht/32/103109_2.png) [@Hans\_Knecht](https://discuss.elastic.co/u/Hans_Knecht)\
**Post date:** [May 25, 2022, 2:12pm UTC](https://discuss.elastic.co/t/setting-environment-for-traces-collected-by-opentelemetry-collector/304160/3 "2022-05-25T14:12:51Z")

</div>

I appreciate the dotnet implementation, the problem is/was that I can't modify these services as they are istio services, not direct code. They are just another network hop. But seeing as they are the same name in each env it made it difficult to separate.

[APM Processing OTEL Collector Attributes to Labels Rather than Attributes · Issue #8074 · elastic/apm-server · GitHub](https://github.com/elastic/apm-server/issues/8074) is the issue I filed, and got a resolution to.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 15, 2022, 10:13am UTC](https://discuss.elastic.co/t/setting-environment-for-traces-collected-by-opentelemetry-collector/304160/4 "2022-06-15T10:13:35Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
