7 ms·
I think all mentioned issues are related to the implementation of the user probes, not the pattern. You mentioned an observation methods, but essentially they
by gobwas 6y ago
I think all mentioned issues are related to the implementation of the user probes, not the pattern.
You mentioned an observation methods, but essentially they are absolutely the same as hooks, just inverted (with a bit less overhead on branching and hook call). E.g. your example with bytesReceived counter can be implemented with atomic operation and further export on demand by some other goroutine.
- jeffbee 6y agoThe thing I keep in mind is that state is mutated far more than it is observed. You might handle 1000 or more requests per second and only export the number of requests once per second or less. In light of this ratio it’s important to make the recording path as simple and cheap as possible, and it’s ok if the observing path has to be complicated to compensate. I usually refuse to use atomic increments for services because it scales very poorly. Even a mutex-protected increment scales much better than atomic increment.
- gobwas 6y agoI see your point that recording must be much cheaper than exporting, and I completely agree with it. Anyway how will you collect that counters inside your component (to be observed later on demand)?