Using Cloud Trace with AppEngine Flex

Hi,

We are migrating from AppEngine Standard to AppEngine Flex (Java 11) and I would like to get Cloud Trace back up and running.

I understand Open Telemetry is now the recommend approach, but I'm getting a bit stuck, even after following the instructions here:

https://cloud.google.com/trace/docs/setup/java-ot

I can create and publish spans, and have verified in my local development environment that the spans are being sent via com.google.cloud.opentelemetry.trace.InternalTraceExporter, but they don't appear in the Cloud Trace console for the given project.

I've tried to get a minimal working version:

public static void main(String[] args) throws InterruptedException {
TraceConfiguration traceConfiguration = TraceConfiguration.builder()
.setProjectId("myprojectid")
.build();
SpanExporter traceExporter = TraceExporter.createWithConfiguration(traceConfiguration);
OpenTelemetrySdk openTelemetrySdk = OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(traceExporter).build())
.build())
.buildAndRegisterGlobal();

TracerProvider tracerProvider = openTelemetrySdk.getTracerProvider();
Tracer tracer = tracerProvider.tracerBuilder("org.myapp").build();
Span span = tracer.spanBuilder("Hello").startSpan();
Thread.sleep(30_000);
span.end();
traceExporter.flush().join(10, TimeUnit.SECONDS);
}

This runs without error, but from the Cloud Console, the trace does not appear:

akbertram_0-1702547967235.png

I also don't understand how to link these spans to the nginx.request log, which already have a traceId and spanId that presumably should be the parent of any spans that I create. I have confirmed that our application receives the X-Cloud-Trace-Context HTTP header in the format 

TRACE_ID/SPAN_ID;o=TRACE_TRUE

But I can't for the life of me figure out how to provide this to my Tracer or TracerProvider instance.

What am I missing?

0 7 597
7 REPLIES 7

Hi @akbertram,

Welcome to Google Cloud Community!

Posting the link to another Google Cloud Community that you referred as an answer:

https://www.googlecloudcommunity.com/gc/Google-Cloud-s-operations-suite/Structured-in-Logging-in-App...

Hope that this would be helpful to other community members.

Hi,

Unfortunately these are two completely unrelated topics!

Still looking for an answer to this question.

Alex

Hi @akbertram,

Apologies about that.

Please check the documentation as you may have missed something in the steps.

If you think that you followed the steps correctly and still don't work as intended, you may file a bug through this link so that our engineers could take a look at this. We don't have a specific ETA however you can keep track of its progress once the ticket has been created.

You may also check this documentation on writing and viewing logs for additional information.

Hope this helps.

Wait, how did this get marked as the accepted solution?

Not only did you not answer my question, but you mixed up two completely different products -- this question is about Cloud Trace, NOT Logging!!

 

Hi,

There doesn't seem to be a lot of documentation about using Cloud Trace together with AppEngine Flex. You mention "Cloud Logging" again, but I am asking about something different - Cloud Trace.

Perhaps someone knowledgeable about the product might share some experience here? Or I have misunderstood the point of this forum?

Best,

Alex

Roderick
Community Manager
Community Manager

Hi @akbertram,

Thanks for your feedback! I'm sorry that we haven't steered you toward the right resources just yet. Let me see if we can share this with a couple internal teams and see if we can surface the right resources. 

Cheers,

Roderick