-
Notifications
You must be signed in to change notification settings - Fork 326
Make it easier to manually report accumulated data #846
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new API surface (ReportUsage) probably needs to be discussed on opencensus-specs first so that other language implementations can also be aware of it. I would recommend that for now we split this PR into two: one that just adds the flush-on-unregister behavior and another with the new API.
stats/view/worker.go
Outdated
@@ -129,6 +129,16 @@ func SetReportingPeriod(d time.Duration) { | |||
<-req.c // don't return until the timer is set to the new duration. | |||
} | |||
|
|||
// ReportUsage immediately reports collected data to all registered exporters | |||
// outside of the regular reporting cycle. | |||
func ReportUsage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new API surface area so probably needs to be discussed on opencensus-specs first so that other language implementations can also be aware of it. I would recommend that for now we split this PR into two: one that just adds the flush-on-unregister behavior and another with the new API.
stats/view/worker_test.go
Outdated
m2 := stats.Int64("measure2", "desc", "unit") | ||
view2 := &View{Name: "count2", Measure: m2, Aggregation: Count()} | ||
|
||
SetReportingPeriod(5 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this test, I would recommend setting the reporting period to something high to emphasize that we don't want the usual reporting cycle to occur.
This might help with census-instrumentation#773.
Thanks for the quick review! I've adjusted this PR to only flush when a view is unregistered. I will also create a discussion issue similar to census-instrumentation/opencensus-specs#126 but focused on stats specifically. |
Thanks @knyar! |
Report data for a given view when it is unregistered.
This might help with #773.