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

statsd: use pystatsd pipeline to send batches #327

Merged
merged 1 commit into from
Nov 27, 2015
Merged
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
4 changes: 3 additions & 1 deletion src/diamond/handler/stats_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def _send(self):
statsd.Counter(prefix, self.connection).increment(
name, value)

if hasattr(statsd, 'StatsClient'):
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

conditional to support both python-statsd and statsd, see also other comment

self.connection.send()
self.metrics = []

def flush(self):
Expand All @@ -152,7 +154,7 @@ def _connect(self):
self.connection = statsd.StatsClient(
host=self.host,
port=self.port
)
).pipeline()
Copy link
Member

Choose a reason for hiding this comment

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

Is there documentation for this feature? Does this call need to be conditional for legacy support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup documented at http://statsd.readthedocs.org/en/v3.2.1/pipeline.html for https://pypi.python.org/pypi/statsd/ and introduced in version 2.0 according to jsocol/pystatsd@51d684e46d

afaict this collector supports both the above and https://pypi.python.org/pypi/python-statsd with the former being actively maintained on github but not the latter, hence the conditional

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to support both versions of the library? Seems like the former offers a superior API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

besides backward compatibility? no idea if there is still a good reason nowadays, possibly not

else:
# Create socket
self.connection = statsd.Connection(
Expand Down