ã¿ã¤ãã«ã¾ã¾ã®è©±ã
GCP ã§ã¯åãããã¯ãã§åºåãããã°ã Cloud Logging ã«éç´ããã¦ã横æçã«è¦ããæ¤ç´¢ãããã§ãã¦å¤§å¤ä¾¿å©ããã£ã«ã¿ã㦠BigQuery ã«æµãè¾¼ããã®ãæé«ãªãæé«ãä»äºã楽ã«ãªãã£ã¦ããã®ã¯ãããããã¨ãã§ã
ãã ããããã¯ããã¨ã«ãã°ã³ã¬ã¯ã¿ã®æåãç°ãªã£ã¦ãã¦å¾®å¦ãªæ°æã¡ã«ãªããã¨ãããããå¤§æµ undocumented ãªãã ããã
ç¹ã«ãæ¨æºåºåã« JSON æååãæ¸ããå ´åã®æåã
- AppEngine 㯠stdout & stderr ã«æ§é åãã°ãæ¸ãããã¨ãããã¥ã¡ã³ãã«æ¸ãã¦ãã
- Cloud Functions ã¯ããã¥ã¡ã³ãã«æ¸ãã¦ããªãã¦ãæåãã©ã³ã¿ã¤ã ã«ãã£ã¦ã¾ã¡ã¾ã¡
- 大æµ
textPayload
ã« JSON æååããã®ã¾ã¾å ¥ã£ã¦ãã
- 大æµ
- Cloud Run ã¯æè¿æ¸ãããããã«ãªã£ã? åã¯ãªãã£ãæ°ã...
Cloud Functions ã®è©±ãããã¨ã2020/2 以åã® Node10 Runtime 㧠JSON ãæ¸ããå ´å㯠textPayload
ã¨ãã¦æ±ããã¦ãããã®ããããæ¥ãããã¼ã¹ãããããã«ãªã£ã¦ãã¦ãæ§é ã Google.Protobuf.WellKnownTypes.Valueã«ãªã£ã¦ãã¾ã£ãããã(ããããã®ã Release Note ã«å
¥ããªãã®ã GCP ã®è¯ããªãã¨ããã ã¨æã)ã
JSON ã stdout ã«åºåãããã¨ã§ãCloud Logging ã«ããæ¸ããã¦ãããã®ã
{ "textPayload": "{\"runtime\":\"nodejs10\",\"key\":\"value\",\"array\":[1,2,3]}", }
ããæ¥ããããæ§é ã«ãªã
{ "jsonPayload": { "fields": { "array": { "Kind": { "ListValue": { "values": [ { "Kind": { "NumberValue": 1 } }, { "Kind": { "NumberValue": 2 } }, { "Kind": { "NumberValue": 3 } } ] } } }, "key": { "Kind": { "StringValue": "value" } }, "runtime": { "Kind": { "StringValue": "nodejs10" } } } } }
ãã®æ§é ã¯èª°ãå¬ããã®ãè¬ã ãã©ãtextPayload
ãæå¾
ã㦠BigQuery ã«è»¢éãã¦ãã人ãããã® jsonPayload
ã«å¤ãã£ããã¨ã§ãããæ¥ãããªãæ°ç¾ã®ã«ã©ã ã«ç´é¢ãã¦ç ´æ»
ãã¦ãã¾ãã¨ããäºä»¶ããã£ãããããããã
ãã¡ãããCloud Functions ããçã£ãæ§é ã§ãã°ãæ¸ãããå ´å㯠Cloud Logging ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªã使ãã¹ãã§ã大æµãããã¦ãããã ãã©ãThe Twelve-Factor App XI. ãã°çã«ããå®è¡ç°å¢ã¸ã®ä¾åãæ¸ããé¢ã§ããstdout ã«æ¸ãã¦æ¸ããªãããããããå®è£ ãç°¡åã«ãªãã
æ¨æ©ãåè¿°ã® Issueã® Status ã Fixed ã«æ´æ°ãããã®ã§ã大åã³ã§åã©ã³ã¿ã¤ã ã§åä½ç¢ºèªãããã
cloud-functions-playground/write-json-stdout at master · pokutuna/cloud-functions-playground
åã確èªã§ããç¯å²ã§ã¯ããããæã
runtime | field |
---|---|
nodejs8 | textPayload |
nodejs10 | jsonPayload |
nodejs12 | jsonPayload |
go111 | jsonPayload |
go113 | jsonPayload |
python37 | textPayload |
python38 | jsonPayload |
java11 | jsonPayload |
Google.Protobuf.WellKnownTypes.Value ã®ãããªæ§é ã«å¤æããããã¨ããªããªããå
ã® JSON ã®æ§é ã®ã¾ã¾ jsonPayload
ã¨ãã¦ä¿åãããããã«ãªã£ã¦ãããdeprecated 㪠nodejs8 ããã®ã¾ã¾ãªã®ã¯åãããã©ãpython37 ã¯ãªãã§ã ãããã
ã¨ãããããã§å¤§æµã®ã©ã³ã¿ã¤ã 㧠Cloud Functions ã«ããã¦ãæ§é åãã°ãã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªãªãã§æ¸ããããã«ãªã£ãã
ãã¶ãç¹æ®ãã£ã¼ã«ããåã㦠{ "logging.googleapis.com/trace": ... }
çã®ãã£ã¼ã«ããæ¨æºåºåã«æ¸ãã° trace ã¨ãã¦æ¾ãããã¨æãããã¡ãã£ã¨ãããã°ã®æ¤ç´¢ããããããªãã
ã¾ãã¡ããã¨ãããå ´åã¯ä¾ç¶ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªã使ãã¹ããªã®ã§ããµããããæã«ä¾¿å©ã£ã¦æããªãã§ãã...
ã§ããã GCP å ã§ã®æ¨æºçãªæåãä»æ§å & å ±éåãã¦ãããªãããªã