Assigned
Status Update
Comments
sn...@google.com <sn...@google.com> #2
Presently, the Cloud Functions engineering team are aware of this request and are assessing it internally. However, at this time there are no set plans to implement or when. But stay tuned here for the outcome.
pw...@greenpeace.org <pw...@greenpeace.org> #3
Are there any good workarounds? This seems pretty important for anyone using cloud functions.
de...@simpleclub.com <de...@simpleclub.com> #4
Couldn't you set up pino with a Transport, where in the transport you use the Node Stackdriver Logging library to send the logs on to Stackdriver.
Keep in mind that you may or may not have to set the resource for Stackdriver (not sure if Cloud Functions gets set automatically...), also you have to set the execution_id label to properly log it as pino would do.
And for the structured logs it may already help to send the structured parts as labels. (I believe labels can only have string keys and values)
E.g.
{
"stringKey": "some string"
"intKey": 49
"objKey": { "key": "Val" }
}
Gets saved in Stackdriver as: Option 1
{
labels: {
"value_stringKey": '"some string"',
"value_intKey": "49",
"value_objKey": '{ "key": "Val" }'
}}
or Option 2
{
labels: {
"value_stringKey": '"some string"',
"value_intKey": "49",
"value_objKey.key": '"Val"'
}}
This would at least help for one level nesting (option 1) or is less beautiful (option 2).
In both examples the values are `JSON.stringify`ed, which will wrap strings in " ", also I have added the prefix "value_" to not interfer with already existing or future labels and you would need to write your own function to convert the structured log to the more simpler labels format.
Of course this depends heavily on your use case and what you try to achieve.
Additional note:
Looking at the logging library it seems like the client SDK should already support objects and arrays:
https://github.com/googleapis/nodejs-logging/blob/master/src/entry.ts#L60
I hope this helps.
Dennis
Keep in mind that you may or may not have to set the resource for Stackdriver (not sure if Cloud Functions gets set automatically...), also you have to set the execution_id label to properly log it as pino would do.
And for the structured logs it may already help to send the structured parts as labels. (I believe labels can only have string keys and values)
E.g.
{
"stringKey": "some string"
"intKey": 49
"objKey": { "key": "Val" }
}
Gets saved in Stackdriver as: Option 1
{
labels: {
"value_stringKey": '"some string"',
"value_intKey": "49",
"value_objKey": '{ "key": "Val" }'
}}
or Option 2
{
labels: {
"value_stringKey": '"some string"',
"value_intKey": "49",
"value_objKey.key": '"Val"'
}}
This would at least help for one level nesting (option 1) or is less beautiful (option 2).
In both examples the values are `JSON.stringify`ed, which will wrap strings in " ", also I have added the prefix "value_" to not interfer with already existing or future labels and you would need to write your own function to convert the structured log to the more simpler labels format.
Of course this depends heavily on your use case and what you try to achieve.
Additional note:
Looking at the logging library it seems like the client SDK should already support objects and arrays:
I hope this helps.
Dennis
Description
A customer wanted to use `pinojs` [1] but had trouble on Cloud Functions. Specifically, it looks like they wanted to use `pino` for structured logs but they were showing up as text in Stackdriver.
@ofrobots can provide additional details if necessary.
[1]