Skip to content

Add support for more environment variables#140

Merged
kbogtob merged 7 commits intoDataDog:masterfrom
delner:delner/env_var_support
Apr 14, 2020
Merged

Add support for more environment variables#140
kbogtob merged 7 commits intoDataDog:masterfrom
delner:delner/env_var_support

Conversation

@delner
Copy link
Copy Markdown
Contributor

@delner delner commented Apr 1, 2020

This pull request adds global tags for:

  • DD_TAGS (acts as base set of global tags, overridden by other tags)
  • DD_ENV --> env:<env name>
  • DD_SERVICE --> service:<service name>
  • DD_VERSION --> version:<version string>

Precedence in order from most to least preferred is manually defined global tags (via #initialize), DD_ENV/DD_SERVICE/DD_VERSION, then finally DD_TAGS.

Copy link
Copy Markdown
Contributor

@remeh remeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
@kbogtob will probably want to give it a look before merging though.

@delner
Copy link
Copy Markdown
Contributor Author

delner commented Apr 2, 2020

@remeh Okay, there's one more question I had... if we set these global tags (say env:staging), and the user passes statsd.count('hits', 1, tags: ['env:staging']), will this produce duplicate env:staging tags? If so would we want to remove this kind of duplication?

Just thinking of the trade-off between saving on packet size vs saving on memory/CPU it would take to de-dup this.

@kbogtob
Copy link
Copy Markdown
Contributor

kbogtob commented Apr 9, 2020

Thanks @delner for your contribution!
I've just fixed some nits to homogenise the code with the existing one and added some tests.

It's true that we don't deduplicate the tags and I think we should be able to override specific tags in this order: ENV < Global tags < Call tags. I will discuss it internally and create an issue.

PS: Thanks for ClimateControl, didn't know that gem before :). It's nice.

@delner delner force-pushed the delner/env_var_support branch from 501c1ba to ebcb740 Compare April 9, 2020 15:44
@delner
Copy link
Copy Markdown
Contributor Author

delner commented Apr 9, 2020

@kbogtob Changes seem fine to me. Also just added a minor fix for a warning that was blowing up our test suite (when we'd close Statsd without using it.)

Comment thread lib/datadog/statsd/serialization/tag_serializer.rb Outdated
Copy link
Copy Markdown
Contributor

@kbogtob kbogtob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just left a small nit.

Comment thread lib/datadog/statsd/serialization/tag_serializer.rb Outdated
@delner delner force-pushed the delner/env_var_support branch from 04a9d62 to cbe3b72 Compare April 9, 2020 16:44
@kbogtob kbogtob merged commit f81533a into DataDog:master Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants