Skip to content

Fix bug where tags list increases in size#94

Merged
yannmh merged 1 commit intoDataDog:masterfrom
steven-liu:fix-constant-tags
Nov 3, 2015
Merged

Fix bug where tags list increases in size#94
yannmh merged 1 commit intoDataDog:masterfrom
steven-liu:fix-constant-tags

Conversation

@steven-liu
Copy link
Copy Markdown
Contributor

Summary

When previously-defined metric-level tags (non-literal list) are passed into the gauge() function,
the metric-level tag list will be modified if constant_tags is not None. This is due
to the += operator modifying the metric-level list by appending
the list constant_tags.

If you're using dogstatsd to send your metrics, this will inevitably lead to a error: [Errno 90] Message too long since the UDP packet size has an upper limit.

For an example of this, see the new test, test_gauge_constant_tags_with_metric_level_tags_twice.

Fix

Use the following instead of +=:

# WILL modify metric-level tags passed into the function
tags += self.constant_tags

# WON'T modify metric-level tags passed into the function
tags = tags + self.constant_tags

When a previously defined tag list is passed into the gauge() function,
the tag list will be modified if constant_tags is not None. This is due
to the '+=' operator modifying the passed-in tag list by appending
constant_tags.
@KyleJamesWalker
Copy link
Copy Markdown

+1

@yannmh
Copy link
Copy Markdown

yannmh commented Nov 3, 2015

Thanks for the fix @steven-liu !

yannmh pushed a commit that referenced this pull request Nov 3, 2015
Fix bug where tags list increases in size
@yannmh yannmh merged commit b5f7d6d into DataDog:master Nov 3, 2015
@yannmh yannmh added this to the 0.11.0 milestone Jan 8, 2016
yannmh pushed a commit that referenced this pull request Mar 1, 2016
Do not modify metric-level `tags` parameters when `constant_tags` is
set.
Similar to #94.
yannmh pushed a commit that referenced this pull request Mar 1, 2016
Do not modify metric/event-level `tags` parameters when `constant_tags`
is set.
Similar to #94.
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.

3 participants