question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tracing does not work well in Cloud Run with TimedBuffer

See original GitHub issue

I have a Cloud Run service behind Cloud Load Balancer. The service is a .NET Core API, utilizing this library to log traces.

If I send 5 concurrent requests, only one gets traced. This is confirmed by checking the Trace List in the Cloud Console, and also the HTTP responses - only the first response has a X-Cloud-Trace-Context header. If I send the 5 requests, but wait for the previous one to complete before sending the next, all 5 get traced. I looked through the options and I tried specifying BufferOptions.NoBuffer() in UseGoogleDiagnostics, but that didn’t seem to make a difference. Am I missing something, or could this be a bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:40 (39 by maintainers)

github_iconTop GitHub Comments

1reaction
amanda-tarafacommented, Sep 23, 2020

There’s no way that you can manually flush the buffer right now. I could expose something via standard dependency injection that would allow you to, from a request. I don’t think it will available on SIGTERM handling though and I wouldn’t do any explicit work for that to be available on SIGTERM. I really really think you don’t need to handle SIGTERM and at that point we won’t guarantee that the Diagnostics library works, some of our dependencies or even our own objects might have been disposed off at that point, etc. All the buffers will flush on Dispose, and Dispose will happen before the application is shut down.

About your solution though, I think it won’t solve your problems, you don’t know which of the Cloud Run instances your special request will hit, there’s no guarantee on the distribution of those hits across your instances, etc. So, you will almost certainly will see delays in tracing, will run into the same problems re the buffer being very big and getting very full if for some reason one of the instances is never hit, etc.

The problem here is that you really want to do something that it’s not supported by the environment you are running in.

1reaction
amanda-tarafacommented, Sep 7, 2020

Just a heads up, a couple other things have come up, but this is still on my TODO for this week. I won’t be looking at it today though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using distributed tracing | Cloud Run Documentation
Incoming requests to Cloud Run services automatically generate traces that you can view in Cloud Trace. You can use these traces to identify...
Read more >
Cloud Run tracing issue with concurrent requests
Cloud Run fails to trace correctly when concurrent requests are made with the same TraceID. Specifically, it forwards the x-cloud-trace-context header to ...
Read more >
Stackdriver-trace on Google Cloud Run failing, while ...
Because Cloud Run services only have resources until they respond to a request, queued up trace data may not be sent before CPU...
Read more >
Cloud Run and Stack Trace Logging : r/googlecloud
Hi all- I'm using cloud run with a docker container running a python app with fast api. Running into an issue with stack...
Read more >
Google Cloud Trace, Debug, Error Reporting | by Hil Liao
Sometimes Trace would show up as quickly as 10 seconds debugging locally at as a single Trace logged. When I hit the cloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found