Brian Bauman
Brian Bauman

Reputation: 1130

OpenCensus Not Showing Traces On Google App Engine in Stack Driver

I am using OpenCensus as recommended by Google Cloud to run StackDriver Trace (https://cloud.google.com/trace/docs/setup/java). My configuration is running on Google App Engine Standard Java 8. I have ensure the API is enabled on the project, used the initialization code and have created spans where I am trying to trace.

I simply create the span with

Span span = tracer.spanBuilder(spanName).startSpan();

and then finish it with

span.end();

It seems straight forward but none of my custom traces were visible in the Google Cloud Trace console, only the default RPC calls traced by Google. I then tried using Scopes instead of Span, initializing StackdriverTraceExporter with and without the project name, but nothing results in creating the custom traces.

Any guidance or suggestion on where to look would be greatly appreciated as this is the first time I am using OpenCensus.

Upvotes: 2

Views: 814

Answers (1)

Brian Bauman
Brian Bauman

Reputation: 1130

I found that OpenCensus has a 5 seconds delay before flushing its cache to write to the exporter location. This means to get the traces to show up, you have to keep the thread alive for at least 5 seconds. The issue I had is in a multithreaded environment, the Threads were dying too fast.

OpenCensus is proposing a chance to that will allow you to pro grammatically flush the cache which will allow developers to flush the cache prior to returning the response which should ensure span data is written out reliably.

Upvotes: 3

Related Questions