本文介绍了是否可以将"initialData"属性可用于将App脚本参数写入Stackdriver消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google建议可以使用具有"initialData"属性的JSON对象将App脚本参数(以及其他数据)写入Stackdriver.但这似乎不起作用.

Google suggests that App Script parameters (among other data) can be written to Stackdriver using a JSON object with a "initialData" property.But it doesn't seem to work.

此Google页面包含一个示例函数,该函数说明了信息可以写入Stackdriver的方式.

This Google page contains an example function that illustrates the different ways information can be written to Stackdriver.

下面是他们自己的代码的摘录:

An extract from their own code is below:

var parameters = {
  isValid: true,
  content: 'some string',
  timestamp: new Date()
};
console.log({message: 'Function Input', initialData: parameters});

运行其应用程序脚本功能时,应将这些参数值写入Stackdriver日志消息中.

When their App Script function is run it should write these parameter values into the Stackdriver log message.

但是在运行并检查了Stackdriver之后,消息(下面的示例)在其中的任何地方都不包含该参数:

But after it's run and Stackdriver is examined the message (example below) doesn't contain the parameter anywhere in it:

{
 insertId:  "s14ubwdkw81"  
 jsonPayload: {
  message:  "Function Input"   
  serviceContext: {
   service:  "AKfycbwcG7JGj9z-yomue0m_bOVdIVyFgDasdsasdsadngdCkk_l"
  }
 }
 labels: {
  script.googleapis.com/deployment_id:  "AKfycbwcG7JGj9z-yomue0m_bOVdsadsad7x7pHYngdCkk_l"   
  script.googleapis.com/process_id:  "EAEA1GOzkIp_aAfasdsadsadsazTnDWNA_ureP83_A8Agfr4IQ9pzSfRzfj1wnw8U_lCUUA4O9afoxyZuCCHYlB5ryBpu0LxfcibIITaoFqdbiVjprxDC5sVIXUAdpnQX3ud0-Xp8t9awJPH484YyeQRsassadZzksNSXYxl4VwcOw"   
  script.googleapis.com/project_key:  "MtcDasfdsfsfsfsfsaduYD4VaIEGs0Nwta"   
  script.googleapis.com/user_key:  "ANbVsadsadasdadashbqPEennz6PO1tasdsadasdfsddg+PjGhPshrkLV1SGwofeIcgpw0"   
 }
 logName:  "projects/project-id-416855555555555555559030426/logs/script.googleapis.com%2Fconsole_logs"  
 receiveTimestamp:  "2019-05-22T15:14:53.355673423Z"  
 resource: {
  labels: {
   function_name:  "measuringExecutionTime"
   invocation_type:  "editor"
   project_id:  "project-id-416855555555555530426"
  }
  type:  "app_script_function"   
 }
 severity:  "DEBUG"  
 timestamp:  "2019-05-22T15:14:52.844Z"  
}

我认为这是Stackdriver或App Script错误,但我想确保自己没有犯错或遗漏任何东西.有什么想法吗?

I think this is a Stackdriver or App Script bug, but I wanted to make sure I hadn't made a mistake or missed something. Any ideas?

进一步的调查表明这可能是一个错误,因为Cloud Function中的相同代码确实按预期工作,Stackdriver提取如下:

Further investigation suggests it probably is a bug, because the same code in a Cloud Function does work as expected, Stackdriver extract below:

{
 insertId:  "000000-7e143986-76f1-5555-b167-8186214f7739"
 labels: {
  execution_id:  "o8r9555cli0j"   
 }
 logName:  "projects/my-project/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp:  "2019-05-16T10:34:26.503211511Z"  
 resource: {
  labels: {
   function_name:  "gcf_htp_function_name"    
   project_id:  "my-project"    
   region:  "us-central1"    
  }
  type:  "cloud_function"   
 }
 severity:  "INFO"  
 textPayload:  "{ message: 'Function Input',
  initialData: 
   { isValid: true,
     content: 'some string'}"  
 timestamp:  "2019-05-23T10:34:21.084Z"  
 trace:  "projects/my-project/traces/a4df23072bfef15269947eaecf3a8f44"  
}

推荐答案

这是一个错误.

Google对其进行了修复.

Google fixed it.

https://issuetracker.google.com/issues/133278375

这篇关于是否可以将"initialData"属性可用于将App脚本参数写入Stackdriver消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 18:11