You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
According to the documentation, Flush waits for exported view data to be uploaded. This is useful if your program is ending and you do not want to lose recent spans.
This is supposed to be for the stats but the comment mentions spans. If this is supposed to work for stats, it is not working.
Here is my test case:
package main
import (
"context""fmt""log""time""go.opencensus.io/exporter/stackdriver""go.opencensus.io/stats""go.opencensus.io/stats/view""go.opencensus.io/tag"
)
varMerrorCount=stats.Int64("razvan.test/measures/error_count", "number of errors encounterd", "1")
var (
ErrorCountView=&view.View{
Name: "demo/razvan/rep_period_test",
Measure: MerrorCount,
Description: "Testing various reporting periods",
Aggregation: view.Count(),
}
)
funcmain() {
KeyMethod, _:=tag.NewKey("test")
ctx:=context.Background()
ctx, _=tag.New(ctx, tag.Insert(KeyMethod, "30 sec reporting"))
// Register the viewsiferr:=view.Register(ErrorCountView); err!=nil {
log.Fatalf("Failed to register views: %v", err)
}
// SD Exportersd, err:=stackdriver.NewExporter(stackdriver.Options{
ProjectID: "opencensus-test",
// MetricPrefix helps uniquely identify your metrics.MetricPrefix: "opencensus-test",
})
iferr!=nil {
log.Fatalf("Failed to create the Stackdriver exporter: %v", err)
}
// It is imperative to invoke flush before your main function exitsdefersd.Flush()
view.RegisterExporter(sd)
// Set reporting period to report data at every second.view.SetReportingPeriod(60000*time.Millisecond)
ticker:=time.NewTicker(1000*time.Millisecond)
i:=0gofunc() {
for {
select {
case<-ticker.C:
stats.Record(ctx, MerrorCount.M(1))
i++
}
}
}()
runtime:=65000time.Sleep(time.Duration(runtime) *time.Millisecond)
fmt.Printf("Incremented %d times\n", i)
}
I only get the value exported after 60 seconds.
The text was updated successfully, but these errors were encountered:
According to the documentation,
Flush
waits for exported view data to be uploaded. This is useful if your program is ending and you do not want to lose recent spans.This is supposed to be for the stats but the comment mentions spans. If this is supposed to work for stats, it is not working.
Here is my test case:
I only get the value exported after 60 seconds.
The text was updated successfully, but these errors were encountered: