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
NopCachedStatsReporter #23
Comments
We've not implemented For testing purposes I will need to use use I've currently worked around it on master by having all tests use an I don't personally use Prometheus so someone else will need to have look into implementing CachedRepoter for Prometheus. |
I have a NopCachedStatsReporter written for testing - https://github.com/uber-go/fx/blob/master/metrics/nop_reporter.go I am happy to share if needed. |
@anuptalwalkar is there any reason you can't use a You can create one by calling func NewTestScope(
prefix string,
tags map[string]string,
) TestScope {
// ...
} Then you get the following abilities: type TestScope interface {
Scope
// Snapshot returns a copy of all values since the last report execution,
// this is an expensive operation and should only be use for testing purposes
Snapshot() Snapshot
}
// Snapshot is a snapshot of values since last report execution
type Snapshot interface {
// Counters returns a snapshot of all counter summations since last report execution
Counters() map[string]CounterSnapshot
// Gauges returns a snapshot of gauge last values since last report execution
Gauges() map[string]GaugeSnapshot
// Timers returns a snapshot of timer values since last report execution
Timers() map[string]TimerSnapshot
}
// CounterSnapshot is a snapshot of a counter
type CounterSnapshot interface {
// Name returns the name
Name() string
// Tags returns the tags
Tags() map[string]string
// Value returns the value
Value() int64
}
// GaugeSnapshot is a snapshot of a gauge
type GaugeSnapshot interface {
// Name returns the name
Name() string
// Tags returns the tags
Tags() map[string]string
// Value returns the value
Value() float64
}
// TimerSnapshot is a snapshot of a timer
type TimerSnapshot interface {
// Name returns the name
Name() string
// Tags returns the tags
Tags() map[string]string
// Values returns the values
Values() []time.Duration
} |
The issue here is doing a setup function to return the scope, reporter and closer can not easily be replaced today. The The use case is something I want to test with as well. If you make a public function to create the metrics with a Example from my use case as well. https://github.com/jeffbean/zkpacket/blob/master/metrics.go |
@robskillington, @jeffbean answered your question. The M3 backend also takes |
Hey, cool no problems. Sure if you don't want to collect the actual values then a |
any update on this? @robskillington |
Not sure about @jeffbean, but FX doesn't need this any more. Unless Bean still needs this functionality, feel free to close this. |
I see that we have implemented
CachedStatsReporter
here, #22 but there is no Nop implementation for testing. This is making transition from StatsReporter toCachedStatsReporter
rather difficult. Do we have any plans to provideNopCachedStatsReporter
similar to existingtally.NullStatsReporter
?The text was updated successfully, but these errors were encountered: