-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CloudTrace : understanding how things are connected #13333
Comments
First take a look at Distributed Tracing in Cloud Run documentation. A few things to note:
If you want to trace more than what the Cloud Run sample rate allows, you'll have to store the traces yourself using Google.Cloud.Trace.V1.TraceServiceClient.PatchTracesAsync. Alternatively you can use Google.Cloud.Diagnostics.Common and Google.Cloud.Diagnostics.AspNetCore3 (works for ASP.NET Core 3 or later) to instrument your code. But please read carefully these notes as they will affect how you need to configure the libraries. |
Hi Amanda
This is true ONLY for HTTP requests Here, this is a pull subscription, meaning that there is no inconming http requests and so there is no trace => this is why I need to manually create one I dont understand this snippet (how am I supposed to start a trace with that snippet ?)
Thanks for the pointers, I'll try "one trace per event" |
Oh, sorry for missing this was for Pub/Sub. So yes, you will have to instrument the code yourself. The snippets we currently have are like code templates, they are not complete (we are working on it). On Google.Cloud.Trace.V1.TraceServiceClient.PatchTracesAsync:
If you look at #6367 (comment), step 3 shows you how to extract and parse the trace context from a Pub/Sub message. The rest of that comment, which is the conclusion of that whole thread, explains how to configure and use Google.Cloud.Diagnostics.Common for tracing non-ASP.NET Core contexts (as is Pub/Sub). You can decide to go with Google.Cloud.Diagnostics.Common or use Google.Cloud.Trace.V1 directly. Let me know if you have more questions, happy to try and help further. |
Thank you, I'll try that and reopen if not enough |
I have a PubSub pull subscriber running on Cloud Run
I'd like to create a new trace for each message AND see the trace "metrics" like for a HTTP request, especially the duration of the trace
At the moment, I'm using this pieece of code (combination of various findings in .NET and GCP docs + multiple tries + previous issues I created on this github) :
The logs are correctly correlated but the trace is not working : I do not have the duration metrics and the icon is not working
I suppose I need to manually integrate with Cloud Trace API to start a Trace
So I looked here : https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest and https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient#Google_Cloud_Trace_V2_TraceServiceClient_CreateSpanAsync_Google_Cloud_Trace_V2_Span_System_Threading_CancellationToken_
However, I do not understand how it works
If I call
CreateSpanAsync
, what do I put inSpanName.FromProjectTraceSpan("[PROJECT]", "[TRACE]", "[SPAN]")
,My understanfing was to use ProjectId, activity.Id, "0000000" => still not showing the trace
Maybe I need to call
BatchWriteSpansAsync
? I tried that too but still not showing the trace=> Can you help or proide pointers ?
The text was updated successfully, but these errors were encountered: