thephpleague / statsd

A library for working with StatsD
MIT License
351 stars 56 forks source link

Reuse socket connection when sending metrics #49

Closed vgarvardt closed 6 years ago

vgarvardt commented 6 years ago

I use your library for statsd backend in our hellofresh/stats-php library. Recently we added quite a lot of new metrics to one of our legacy monolith project to profile some bottlenecks and found that although metrics are sent via UDP we got significant performance degradation. During the investigation we found that statsd opens new socket connection for every metric being sent, that is quite expensive operation.

I fixed the issue in our library - https://github.com/hellofresh/stats-php/pull/3 (we tested it before merging), but I think it would be useful to have this feature/fix in the base library.

marcqualie commented 6 years ago

Great catch @vgarvardt!

Everything seems to work and tests pass so I'm good with this. Clean abstraction to a function as well.

One tiny thing regarding the comments, could you possibly update to stick with the current format of comments that the rest of the files have for consistency?

Thanks /Marc

vgarvardt commented 6 years ago

@marcqualie sorry about that - applied autoformatting to the file with my default code style. Should be fixed now.

marcqualie commented 6 years ago

Thanks for the great contribution @vgarvardt!

vgarvardt commented 6 years ago

@marcqualie what is the release cycle of the library? Is there estimated date when the patch will be available in the release version?