Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Google Stackdriver错误报告API-包含自定义数据_Node.js_Google Cloud Platform_Stackdriver_Google Cloud Error Reporting - Fatal编程技术网

Node.js Google Stackdriver错误报告API-包含自定义数据

Node.js Google Stackdriver错误报告API-包含自定义数据,node.js,google-cloud-platform,stackdriver,google-cloud-error-reporting,Node.js,Google Cloud Platform,Stackdriver,Google Cloud Error Reporting,我需要包括一个带有错误报告的自定义数据对象/JSON字符串,而不会丢失Stackdriver似乎捕获的stacktrace。将JSON字符串设置为消息似乎不是理想的解决方案 我在网上看到了对jsonPayload键的引用,但没有成功地在报告中设置它 在Node.js系统中,我将Stackdriver集成到(通过logging client)中,我有一个logger函数,它可以接受有关环境、错误堆栈和导致错误的任何支持数据的附加数据,我希望将其包含在报告中,以便能够快速调查这些数据 在此期间,我不

我需要包括一个带有错误报告的自定义数据对象/JSON字符串,而不会丢失Stackdriver似乎捕获的stacktrace。将JSON字符串设置为
消息
似乎不是理想的解决方案

我在网上看到了对
jsonPayload
键的引用,但没有成功地在报告中设置它

在Node.js系统中,我将Stackdriver集成到(通过logging client)中,我有一个logger函数,它可以接受有关环境、错误堆栈和导致错误的任何支持数据的附加数据,我希望将其包含在报告中,以便能够快速调查这些数据

在此期间,我不得不使用GoogleStackDriver日志API来处理这个问题,但我发现metrics viewer有点复杂,而且很难跟踪处理了哪些日志

我以前在这上面看到过一个,但我不想劫持它。也没有任何解决办法


希望有解决办法

我要做的是将自定义负载存储到数据存储中,并将指向数据存储查看器的链接放到错误异常消息中。下面是它在Ruby中的外观示例(该方法将调试所需的
url
html
字符串存储为
exception\u details
类数据存储实体的属性):

这是我收到的一封电子邮件:

我没有点击蓝色按钮,而是访问了超链接,在那里我现在可以检查我存储的
html
变量:


感谢您如此详细的回复。看起来是个很好的解决办法。我将在我的开发部门试用。现在我已经改用Sentry,因为它可以快速简单地设置上下文
def report_error url, html
  begin
    raise "https://console.cloud.google.com/datastore/entities/query/gql?gql=#{
            CGI.escape "SELECT * FROM exception_details WHERE __key__=Key(exception_details, #{
              Datastore.save( Datastore.entity("exception_details") do |error|
                error["url"] = url
                error["html"] = html
                error.exclude_from_indexes! "html", true
              end ).first.key.id
            })"
          }"
  rescue => e
    Google::Cloud::ErrorReporting.report e
  end
end