ruby-on-railsgoogle-kubernetes-enginestackdrivergoogle-cloud-stackdrivergoogle-cloud-error-reporting

Ruby exceptions not appearing in Google Cloud Error Reporting


I have a Rails app running in GKE and I'm trying to set up Google Cloud Error Reporting. I have installed the stackdriver gem and required it on application startup. I can manually report errors from the Rails console without issue, but they don't appear in the GCP Error Reporting UI.

irb(main):021:0> Google::Cloud::ErrorReporting.report(Exception.new(msg: "from console")).result
=> [true, [], nil]

I also confirmed that it's configured with the correct project_id and that I'm looking at the correct project in the GCP UI.

UPDATE

I used the code snippet found here and replaced $stderr with $stdout and changing the log level to DEBUG to get some insight into the RPC call. When I tried to report another exception in the console, I saw the following...

Failing with status #<struct Struct::Status code=7, details="User not authorized.", metadata={}, debug_error_string="UNKNOWN:Error received from peer ipv4:xxx.xxx.xxx.xx:443 {grpc_message:\"User not authorized.\", grpc_status:7, created_time:\"2024-05-23T17:54:30.826579798+00:00\"}">

Seeing this "User not authorized" error, I checked the service account's assigned roles and saw that it didn't have the necessary errorreporting.errorEvents.create role. Once that was added, I was able to report and exception and see it appear in the Error Reporting UI.


Solution

  • There might be an issue with configuring the GCP Error Reporting, below steps may help you to resolve the issue:

    Also check this Github document on google-cloud-error_reporting for more details.