metrics icon indicating copy to clipboard operation
metrics copied to clipboard

add an efficient labels serializer

Open ftelnov opened this issue 2 years ago • 1 comments
trafficstars

What has been done? Why? What problem is being solved?

I found out that observe method works slow. Further investigations showed that make_key function sorts keys every run time. make_key is being called often during, for instance, hist:observe. To optimize this case and both keep the default behavior, I propose two things:

  1. Allow user to override labels_pairs serialization scheme with __metrics_make_key meta-method. If it is supplied, it would be used, otherwise the default sorting scheme would be used;
  2. Provide precaching labels serializer. It would order the labels properly on the client side, and only concat pairs on the metrics side. The complexity is linear then.

I didn't forget about

  • [x] Tests
  • [x] Changelog
  • [ ] Documentation (README and rst) (don't think I should alter it for such a small api?)
  • [ ] Rockspec and rpm spec (I don't really know what to add here)

ftelnov avatar Nov 03 '23 07:11 ftelnov

This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

github-actions[bot] avatar Jan 02 '24 18:01 github-actions[bot]