-
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
Google.Cloud.Logging.Console : getting / setting the traceId manually ? #11042
Comments
I'll assign this to Amanda in case I've missed something, but I believe the trace ID is just |
Getting the Trace ID is as @jskeet said, you just use Setting the Trace ID and it having an effect in the exported data, depends. This is briefly described in Google.Cloud.Loggin.Console documentation. In particular: For initializing or modifying the Activity ID:
But, you'd need to make sure that those "custom" traces are exported, i.e. you'd need to write explicit code to export them.
|
@christopheblin: Does that answer everything you need? |
Hi , Thanks to the pointers given by Amanda, I found out that to set the traceId of the Activity.CUrrent, you need to do
To find traceId and spanId, I read https://cloud.google.com/run/docs/trace So I am currently trying to make it work with "traceparent". I think I can close this issue because my question is answered |
For the record, the problem is not that cloud run override the header on its own BUT you must start a new activity in order for it to work in Cloud run (no idea why, I do not see how it makes a difference...)
instead of the more simpler version that only works locally
|
OK I now understand why we need to start a new activity in Cloud run : Activity.Current.Parent is already populated (I do not know by who or how) and so it is ignored To see why it is ignored, look at https://github.com/dotnet/runtime/blob/main/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs#L574 Basically,
The In .NET 7+, the restriction is even more hard because the SetParentId can only be called before .Start()
so in the end, I'm glad to have the bug before .NET 8 :) |
After #9948, the result is that using a simple stdout logger allows to correlate all logs of the same HTTP request because they have the same "trace"
Which allows a nice view like this where you can fold/unfold logs of the same trace
My question : is there a way to manually get / set the id of the trace ?
The text was updated successfully, but these errors were encountered: