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

#44 Metrics init draft #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

EdgarSedov
Copy link

@EdgarSedov EdgarSedov commented Mar 10, 2021

#44
Hi, i've made a working draft of these mechanics (currently only for redis). Please take a look.

@EdgarSedov EdgarSedov force-pushed the metrics-initial-values branch 5 times, most recently from ef6aecc to d4b1349 Compare March 11, 2021 18:52
* @return void
*/
public function wipeStorage(): void;
public function initHistogram(array $data): void;
Copy link
Member

Choose a reason for hiding this comment

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

Adding new methods to this interface is a breaking change, we should avoid doing it or maybe release this as a new version afterward (lesson learned from #43)

@LKaemmerling
Copy link
Member

Hey @EdgarSedov,

looks okay for me, but can you also please add tests?

Copy link
Author

@EdgarSedov EdgarSedov left a comment

Choose a reason for hiding this comment

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

Hey @EdgarSedov,

looks okay for me, but can you also please add tests?

Thanks! I guess 'll have some time a bit later this week, and will fix everything and add more tests

$metricKey = $this->toMetricKey($data);

// If hash exists, we skip init
if ($this->redis->hLen($metricKey)) {
Copy link
Author

Choose a reason for hiding this comment

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

The problem i can see here is what this condition blocks us from second init with another labels pool.
It can be made wiser, fetching data from __meta and comparing, but for now i just want to know if this concept is acceptable at all

/**
* @param array[] $labelValuesSet
*/
public function init(array $labelValuesSet = []): void
Copy link
Author

Choose a reason for hiding this comment

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

Using such methods we can leave it to user to decide if he needs init or not, so there will be no changes in behaviour for regular usage

@EdgarSedov
Copy link
Author

I haven't forgotten about this, just don't have enough time atm. Redis and InMemory are ready, only APC Adapter left

@EdgarSedov
Copy link
Author

Sorry, i'm not sure i can make enough time to code this properly (add support for all drivers, extend this for summaries, add labels "update" support after first init).
Atm did rebase and going to check if redis init is working at all.

If anyone could catch it or at least contribute implementation of missing drivers, that would be great.

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.

2 participants