It works fines and traces are sent to the specified Elastic APM endpoint URL.
I also need to distinguish between deployment environments (test, stage, prod), this is done by setting hostContext.HostingEnvironmentName to the respective value. But the value is ignored by the Elastic APM. I tried other alternative like Environment.SetEnvironmentVariable("ELASTIC_APM_ENVIRONMENT", "test"), but nothing worked.
I know if I import ElasticAPM NuGet packages it will do this for me, but I would like to stay with bare OTLP Exporter. Is it possible to specify environment name in that case?
for this, you'll need to configure the .NET OpenTelemetry OTLP Exporter to send the environment. It's worth to keep in mind that that component is not from Elastic, so that's why the ELASTIC_APM_ENVIRONMENT is ignored - that is known to the Elastic .NET APM Agent (and other Elastic APM Agents) - but not for the OpenTelemetry agent.
I think you can do this with the .NET OTel libraries as well. Could you try something like this?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.