-
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.Diagnostics does not seem to be working with BackgroundService #4855
Comments
I'm looking into this. Will get back when I know more. |
In your first post:
Can I confirm that the package you are using is Google.Cloud.Diagnostics**.AspNetCore** 4.0.0? |
Ah yes. I'll update the post. Sorry about that. |
@mahesh-bennie What you are seeing is not an issue with the Diagnostics library, it's just working as intended. Attached you'll find a working example. My controller has two actions, Note that for Let me know if this answers your question. |
@mahesh-bennie Any luck trying my code? Any remaining related questions? |
@amanda-tarafa Hey thanks for responding and providing a great solution! I'm going to try it out now and will let you know of the results. |
@amanda-tarafa It worked fantastically! I can see all the traces flowing through. I guess the TraceHeaderContext.Create was the piece I was missing. In order to get my delegate handler to work with the trace, all I needed to do was invoke ContextTracerManager.GetCurrentTracer() and it just worked! Thanks again so much for not just stopping with "oh that's how its designed" but with an actual working example! |
Environment details
Problem Description
Been trying to get tracing information over to GCP by following this documentation (http://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Diagnostics.AspNetCore/)
I've noticed that none of the tracing information (nor metrics and error logs) flow through to GCP when execution occurs in a background service (as implemented following this example https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio#queued-background-tasks). I did however, notice that everything shows up if I don't use background service (aka just hitting the method directly from the controller instead of queuing it up).
Is this a known issue? Is there something I need to pass along to the background service in order to get information flowing? This is a snippet of how I establish tracing (I'm just trying to obtain tracing anytime we perform http requests on our httpclient)
This is what is currently happening in my endpoint (which doesn't work):
QueueWork does the following:
_taskQueue.QueueBackgroundWorkItem is basically a copy of the implementation in the article described above.
Now if the controller were to call _example.PerformWork directly, then I do see trace logs on GCP.
The text was updated successfully, but these errors were encountered: