1

I am new to GCT. For most examples I found online, the start and end of a span are on the same machine (or even the same function like defer span.Close()). E.g.

try (Scope ss = tracer.spanBuilder("ChildSpan").startScopedSpan()) {
...
}

Meanwhile my system is comprised of many message-driven micro-services with async APIs.

When an ingress micro-service receives a request, it handles it, send a message to a message queue and then return. Some other micro-services would listen to the message queue and continue with the process till the very end (e.g. a final report is generated and stored).

How can I start and end the root span in this case? This might have something to do with the context propagation, but please help with some concrete example codes or APIs to use in order to show how this can be done in Google Cloud Trace. Thanks.

aXqd
  • 733
  • 5
  • 17
  • 1
    For examples can you check these documentations on distributed google cloud trace [DOC1](https://cloud.google.com/architecture/microservices-architecture-distributed-tracing) [DOC2](https://cloud.google.com/architecture/using-distributed-tracing-to-observe-microservice-latency-with-opencensus-and-stackdriver-trace#review_opencensus_instrumentation) – Dharani Dhar Golladasari Mar 24 '23 at 09:41
  • @DharaniDharGolladasari Thanks for your comment. However, the examples provided in those links are similar to what I mentioned. i.e. the functions startSpan() and span.end() are executed on the same machine. I might misunderstand how span works. But my objective is to initiate the root span in one micro-service when a new request is received and then conclude the root span in a different micro-service when the entire task is completed. This way, the root span will display the overall time taken, and in each micro-service, I can create a child span to show more detailed latencies. – aXqd Mar 24 '23 at 17:29
  • I think I start to get it. It seems parent span can end before the end of the child span, hence in the ingress micro-service, I can just end the root span, then it looks like a waterfall instead of an onion for the whole trace. – aXqd Mar 24 '23 at 19:57

0 Answers0