-
Notifications
You must be signed in to change notification settings - Fork 327
stats/view: add Flush to immediately report all collected data points regardless of buffering #862
Comments
Thank you for filing this issue @lychung83! So currently, I think the idiomatic fix here would to add a global function to view called say |
I think we need a global Flush function that reports all the collected points. |
@rakyll perhaps I am bikeshedding or not, on the name: I thought of |
Flush function I was suggesting is not stopping the worker, it only flushes the unprocessed data points. Exporting a function that stops the worker might need more thinking because we never planned to give control of the worker to the user entirely. Also, in practice, should you care about what's collected after you flushed due to the termination signal? |
Roger that, that would work. And in deed, users can invoke
@lychung83 is this an actual problem that you've encountered or were you hypothesizing based off reading the code? I too don't think it should matter, and moreoever we haven't even provided a stop method nor does the worker know when we are terminating except by the Go runtime cleaning up. |
To me, Flush() (not stopping the worker) seems enough. My use cases are:
|
Okay, am retitling this issue then as Flush is request that is different from the original request of when a program is exiting. |
Flush is a global function that immediately reports all collected data by the worker, regardless of the reporting duration or buffering. Added tests but also ensured that calling (*worker).stop() then Flush doesn't block and returns ASAP if the state is "quit". The required protected w.quit from double close but also using a select to detect cases of forever waiting channel `w.quit` which was closed. Fixes census-instrumentation#862
Flush is a global function that immediately reports all collected data by the worker, regardless of the reporting duration or buffering. Added tests but also ensured that calling (*worker).stop() then Flush doesn't block and returns ASAP if the state is "quit". The required protected w.quit from double close but also using a select to detect cases of forever waiting channel `w.quit` which was closed. Fixes census-instrumentation#862
This will solve census-ecosystem/opencensus-go-exporter-stackdriver#43. |
I don't think we should have a separate function to flush each Exporter and one to flush the internal stats buffer. We should have a single global Flush/Shutdown/Close function that only returns when everything has been flushed. It's also important that things get flushed in the right order: flushing the internal stats before flushing the buffer in the exporter will not work as intended. Users should not have to find this out themselves. |
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Updates #63
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Updates #63
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Updates #63
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Updates #63
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Updates #63
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Also replace grpc.NewServer with a stats enabled server helper call. This enables tracing and metrics for each gRPC server by replacing naked usages of grpc.NewServer with the new helper function: internal.GRPCServerWithObservabilityEnabled Updates #63
Flush is a global function that immediately reports all collected data by the worker, regardless of the reporting duration or buffering. Added tests but also ensured that calling (*worker).stop() then Flush doesn't block and returns ASAP if the state is "quit". The required protected w.quit from double close but also using a select to detect cases of forever waiting channel `w.quit` which was closed. Fixes census-instrumentation#862
For metrics, concept of Reader was added recently. With reader one can call ReadAndExport to export all data on program termination. It would work same as flush. |
Instrument interceptor/opencensus with stats to record the number of received spans. This is accomplished by a helper to process spans that sends over spans even if the number of spans is 0. Also record with tag_key "opencensus_interceptor" whose value is the name of the respective interceptor. The test to ensure that 0 length spans are also added is currently disabled because: * Issue census-instrumentation/opencensus-go#862 is not yet implemented which requests that the OpenCensus-Go stats worker provide a method Flush to flush all data. Without it, metrics will contain stale data from previous tests. Add tests to lock-in this behavior. Also replace grpc.NewServer with a stats enabled server helper call. This enables tracing and metrics for each gRPC server by replacing naked usages of grpc.NewServer with the new helper function: internal.GRPCServerWithObservabilityEnabled Updates census-instrumentation#63
Hi @odeke-em, I noticed one of your commits mentioned in this issue addresses this problem directly, so I'm just wondering if you'll eventually open it as a PR or if there's anything blocking it. Thank you! 🎉 |
Hey Marwan,
Thank you for the ping! I did open up a PR but it got blocked because
there was no consensus/movement to add it via OpenCensus Specs and I
believe these libraries are now on auto pilot mode and no longer adding
features so unfortunately I don’t think it’ll be done. My PR was sent for
over a year.
…On Sat, Nov 2, 2019 at 1:27 PM Marwan Sulaiman ***@***.***> wrote:
Hi @odeke-em <https://github.com/odeke-em>, I noticed one of the commits
mentioned in this issue addresses this issue directly, just wondering if
you'll eventually open it as a PR or if there's anything blocking it. Thank
you! 🎉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#862?email_source=notifications&email_token=ABFL3V72S2566O257GETAJLQRXPEDA5CNFSM4FOTOTXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5EJYI#issuecomment-549078241>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFL3V47TL2GLTABDLWOVDDQRXPEDANCNFSM4FOTOTXA>
.
|
@odeke-em Thank you for the response. This seems to me more of a bug than a feature since OpenCensus swallows metrics when a process exists. In the same spirit, does that mean all other features and bug requests are frozen? I recently opened this issue which, if my assumption is correct, would be quite noteworthy to address: #1181 Thanks again :) |
Problem:
When exiting a program running opencensus monitoring, some of the data are not passed to exporter. This happens because as one can see in following code, reportUsage() is called only by timer, so when program exists, all data passed to opencensus after last timer firing event are simply lost.
Solution proposal:
func (w *worker) stop()
to be (indirectly) callable by client of package.func (w *worker) start()
to callw.reportUsage()
before returning when<-w.quit
is triggered.The text was updated successfully, but these errors were encountered: