@@ -621,7 +621,7 @@ def initialize(*_)
621
621
o . env_parser do |env_value |
622
622
# Parses a string containing key-value pairs and returns a hash.
623
623
# Key-value pairs are delimited by ':' OR `=`, and pairs are separated by whitespace, comma, OR BOTH.
624
- values = { }
624
+ result = { }
625
625
unless env_value . nil? || env_value . empty?
626
626
# falling back to comma as separator
627
627
sep = env_value . include? ( ',' ) ? ',' : ' '
@@ -631,28 +631,19 @@ def initialize(*_)
631
631
next if tag . empty?
632
632
633
633
# tag by : or = (for OpenTelemetry)
634
- key , val = if tag . include? ( ':' )
635
- tag . split ( ':' , 2 ) . map ( &:strip )
636
- elsif tag . include? ( '=' )
637
- tag . split ( '=' , 2 ) . map ( &:strip )
638
- else
639
- [ tag . strip , '' ]
640
- end
641
- next if key . empty?
642
-
634
+ key , val = tag . split ( /[:=]/ , 2 ) . map ( &:strip )
635
+ val ||= ''
643
636
# maps OpenTelemetry semantic attributes to Datadog tags
644
- case key . downcase
645
- when 'deployment.environment'
646
- key = 'env'
647
- when 'service.version'
648
- key = 'version'
649
- when 'service.name'
650
- key = 'service'
651
- end
652
- values [ key ] = val
637
+ key = case key . downcase
638
+ when 'deployment.environment' then 'env'
639
+ when 'service.version' then 'version'
640
+ when 'service.name' then 'service'
641
+ else key
642
+ end
643
+ result [ key ] = val unless key . empty?
653
644
end
654
645
end
655
- values
646
+ result
656
647
end
657
648
o . setter do |new_value , old_value |
658
649
raw_tags = new_value || { }
0 commit comments