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

feat(datadog): add environment variable configuration #836

Conversation

majorgreys
Copy link
Contributor

Resolves #824

Adds support for unified service tagging with environment variables DD_SERVICE, DD_ENV, DD_VERSION as well global tags with environment variable DD_TAGS.

https://docs.datadoghq.com/tracing/setup/python/#configuration
https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging

@majorgreys majorgreys requested a review from a team June 17, 2020 04:53
Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for getting to this so quick.

self.agent_url = (
agent_url
if agent_url
else os.environ.get("DD_TRACE_AGENT_URL", DEFAULT_AGENT_URL)
)
self.service = service if service else os.environ.get("DD_SERVICE")
self.env = env if env else os.environ.get("DD_ENV")
Copy link
Member

Choose a reason for hiding this comment

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

an empty string evaluates to false, so you may find that you cannot set that as a value (although I'm not sure what an empty string would do with regards to tag values anyway. It may not be valid).

also a shorthand for this is:
self.env = env or os.environ.get("DD_ENV") (evaluates to first non-falsey value)

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

LGTM!

"DD_SERVICE": "test-service",
"DD_ENV": "test",
"DD_VERSION": "0.0.1",
"DD_TAGS": "team:testers",
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't look like there's any test coverage for multiple tags with , separators

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up, added it to one of the tests!

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

lgtm

@codeboten codeboten merged commit 99cb046 into open-telemetry:master Jun 18, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 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.

datadog: honor DD environment variables
4 participants