Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the DD_TAGS environment variable #18

Merged
merged 1 commit into from
Sep 29, 2020
Merged

Add support for the DD_TAGS environment variable #18

merged 1 commit into from
Sep 29, 2020

Conversation

oskarpearson
Copy link
Contributor

Datadog agent uses a standard environment variable DD_TAGS which you can use to
set custom tags like the environment you're running in, the class of host,
and similar.

Prior to this version, the user could set only two tags: MY_POD_NAME
and STATSD_GROUPING.

This commit changes things so that:

  • Stats sent now include tags set in the DD_TAGS environment variable,
    while keeping backwards compatibility with the MY_POD_NAME and STATSD_GROUPING
    environment variables.
  • The 'tags' method isn't run once for every metric sent, since the result never
    changed from run-to-run. We now use a 'environment_variable_tags' method instead.
  • The 'environment_variable_tags' method returns a string, rather than a hash.
    While datadog metrics are normally key/value pairs, you can create so-called
    'simple tags' which are just a string. For example, you may have a tag called
    "canary", and if it exists then the stats are from a canary instance.

Additional changes:

  • Add section to the documentation on usage of DD_TAGS

Datadog agent uses a standard environment variable DD_TAGS to set custom tags
like the environment the code is running in, the class of host, and similar.

Prior to this commit, the user could set only two tags: MY_POD_NAME
and STATSD_GROUPING.

Here, we change things so that:

- The DD_TAGS environment variable can now be used to set custom tags using
  the standard tag syntax, while keeping backwards compatibility with the
  MY_POD_NAME and STATSD_GROUPING environment variables.
- The 'tags' method isn't unnecessarily executed once for every metric sent,
  since the result never changed from run-to-run or metric-to-metric. We now use
  a 'environment_variable_tags' method once at startup.
- The 'environment_variable_tags' method also now returns a string, rather than
  a hash. While datadog metrics are _normally_ key/value pairs, you can also create
  so-called 'simple tags' which are just a string with no specific value. For
  example, you might have a tag called "canary", and if it exists then the
  stats are from a canary instance.

Additional changes:

- Add section to the documentation on usage of DD_TAGS
- Add clearer differentation of the ways that you can set tags in the
  documentation.
@yob yob merged commit 590a880 into yob:master Sep 29, 2020
@yob
Copy link
Owner

yob commented Sep 29, 2020

Lovely, thanks!

The kube-specific ENV vars always bothered me a bit, using a DD specific ENV var for a DD specific feature is much nicer.

@oskarpearson oskarpearson deleted the add-support-for-ddtags-env-var branch September 29, 2020 14:49
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.

2 participants