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

Support space-separated DD_TAGS #289

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/datadog/statsd/serialization/tag_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def escape_tag_content(tag)
def dd_tags(env = ENV)
return {} unless dd_tags = env['DD_TAGS']

to_tags_hash(dd_tags.split(','))
separator = dd_tags.include?(',') ? ',' : ' '
to_tags_hash(dd_tags.split(separator))
end

def default_tags(env = ENV)
Expand Down
16 changes: 15 additions & 1 deletion spec/statsd/serialization/tag_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
end

context '[testing management of env vars]' do
context 'when testing DD_TAGS' do
context 'when testing DD_TAGS with commas' do
around do |example|
ClimateControl.modify(
'DD_TAGS' => 'ghi,team:qa'
Expand All @@ -159,6 +159,20 @@
end
end

context 'when testing DD_TAGS with spaces' do
around do |example|
ClimateControl.modify(
'DD_TAGS' => 'ghi team:qa'
) do
example.run
end
end

it 'correctly adds individual tags' do
expect(subject.format([])).to eq 'ghi,team:qa'
end
end

context 'when testing DD_ENTITY_ID' do
around do |example|
ClimateControl.modify(
Expand Down
2 changes: 1 addition & 1 deletion spec/statsd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
'DD_ENV' => 'staging',
'DD_SERVICE' => 'billing-service',
'DD_VERSION' => '0.1.0-alpha',
'DD_TAGS' => 'ghi,team:qa'
'DD_TAGS' => 'ghi team:qa'
) do
example.run
end
Expand Down