spandex-project / spandex

A platform agnostic tracing library
MIT License
335 stars 53 forks source link

Customize environment name #98

Closed andrepintorj closed 4 years ago

andrepintorj commented 5 years ago

Looks like the environment variable name posted to Datadog is always set as "env" in the sense of when browsing through DataDog's APM screens it is possible to filter for "env". The point here is that I have many other applications posting the "env" as "environment" thus I end up having 2 filters: env and environment.

Is there a way to customize the "env" var name to "environment"?

In the snippet below, if I try to change env and name it as environment I get an error since environment is not a recognized parameter...

Tracer.configure( service: :booking, adapter: SpandexDatadog.Adapter, disabled?: tracing_disabled, env: "#{apm_tracing_env}" )

bforchhammer commented 5 years ago

For what it's worth: we ran into the same problem and ended up going the other way, i.e. tagging any other resources also with env instead of environment...

GregMefford commented 5 years ago

I believe that env is the name that the Datadog Agent applies as a tag by default, correct? I'm not clear on how you would end up with both env and environment tags, unless you have other applications that are setting the environment tag manually.

In the Datadog Agent config, you can set custom tags in addition to the default ones, so maybe that's what you're looking for, if it's a constant for your whole application.

If you want to set span metadata on an span basis, you can use the Tracer.update_span(tags: [environment: apm_tracing_env]) syntax, but I'm not sure if that's what you're trying to achieve or not.

zachdaniel commented 4 years ago

No response, and the answer seems to have been explained well by @GregMefford, closing.