Skip to content

Update Statsd tag serializer to allow falsy values #326

@joseph-hughes

Description

@joseph-hughes

Please, see #290 for all details.

PR description at the time of opening this issue:

Problem

If we provide a tag which has a boolean value, we are unable to properly track the false case, since the "true" string appears with the tag name, but the "false" string does not show up. This is because of this logic, which checks for tag value presence:

def to_tags_list(tags)
case tags
when Hash
tags.map do |name, value|
if value
escape_tag_content("#{name}:#{value}")
else
escape_tag_content(name)
end

true is evaluated to present, so we would add that tag name and value; however, false is evaluated to not present, so we would only add that tag name (not the value).

Solution

First, check for nil explicitly then also check for nil after converting to a string.

This does result in other values being deemed "present" now which were not previously though, such as [] and {}. Is this a problem though?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions