可以使用“ initialData”属性将App脚本参数写入Stackdriver消息吗?

时间:2019-05-22 16:05:22

标签: json google-apps-script google-cloud-stackdriver

摘要

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

问题示例

This Google page包含一个示例函数,该函数说明了可以将信息写入Stackdriver的不同方式。

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

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

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

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

{
 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错误,但我想确保自己没有犯错或遗漏任何东西。有什么想法吗?

更新

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

{
 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"  
}

1 个答案:

答案 0 :(得分:1)

那是个错误。

Google对其进行了修复。

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