File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,13 @@ func NewTestScope(
120120 return newRootScope (ScopeOptions {Prefix : prefix , Tags : tags }, 0 )
121121}
122122
123+ // NewReportableScope creates a new ReportableScope with a set of options.
124+ // Must provide either a StatsReporter or a CachedStatsReporter.
125+ func NewReportableScope (opts ScopeOptions ) ReportableScope {
126+ s := newRootScope (opts , 0 )
127+ return s
128+ }
129+
123130func newRootScope (opts ScopeOptions , interval time.Duration ) * scope {
124131 sanitizer := NewNoOpSanitizer ()
125132 if o := opts .SanitizeOptions ; o != nil {
@@ -181,6 +188,10 @@ func newRootScope(opts ScopeOptions, interval time.Duration) *scope {
181188 return s
182189}
183190
191+ func (s * scope ) Report () {
192+ s .reportLoopRun ()
193+ }
194+
184195// report dumps all aggregated stats into the reporter. Should be called automatically by the root scope periodically.
185196func (s * scope ) report (r StatsReporter ) {
186197 s .cm .RLock ()
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ type Scope interface {
5959 Capabilities () Capabilities
6060}
6161
62+ // ReportableScope is a wrapper arround Scope with Report method for manual reportig data.
63+ type ReportableScope interface {
64+ Scope
65+
66+ // Manual report metrics from scope and subscopes to reporter
67+ Report ()
68+ }
69+
6270// Counter is the interface for emitting counter type metrics.
6371type Counter interface {
6472 // Inc increments the counter by a delta.
You can’t perform that action at this time.
0 commit comments