Conversation
Signed-off-by: Vladimir Buyanov <b.vladimir@clickadu.com>
bwplotka
left a comment
There was a problem hiding this comment.
Thanks!
This is great in general, but unfortunately, given a high adoption of this library, we need to embrace an extremely low tolerance bar for breaking changes. Those minimal changes, multiplied by hundreds of thousands importers mean combined effort of likely a multiple SWEyears without notice (next automatic pull of the release of client_golang). There are things we could do without breaking changed, but even replacing struct with interfaces etc is hard to accept now.
However, we were always thinking about v2, you can find many issues/ideas that require v2 on our board, so perhaps it's time to start something together on a branch of directory? With generics now, things might be bit easier. V2 will be a long process to get, and it will need to be 10x easier to use to get ppl on it... but we need to start it one day (:
Hello.
While working on #1854 I ran into a few typing issues that got in the way:
Most types like
Counter,Gauge,Histogram, andSummaryhave both an interface and a concrete private implementation (counter,gauge, etc.) that implements it. But for the vector types (CounterVec,GaugeVec) there’s no interface — they’re implemented directly. I introduced interfaces for these vector types and moved the implementations into private types (counterVec,gaugeVec).The
ObserverVecinterface forHistogramVecandSummaryVecimplements all its methods and also satisfiesCollector. However, forHistogramandSummary, theObserverinterface only definesObserve(float64). This prevents creating a generic interface forHistogramandSummaryin places that require aCollectorimplementation. I added the missing methods toObserverand introduced a newObserverMetodinterface.Added the missing methods to
ObserverVec.All *Vec types use
MetricVecunder the hood. I also turnedMetricVecinto an interface.I tried to maintain maximum backward compatibility to minimize the likelihood of changes in existing projects.
In most cases, everything will work without changes or with minimal changes (for example, replacing type from pointer to the interface --
*CounerVec=>CounerVec)