GoogleCloudPlatform / functions-framework-nodejs

FaaS (Function as a service) framework for writing portable Node.js functions
Apache License 2.0
1.28k stars 158 forks source link

feat: add execution id support #592

Closed liuyunnnn closed 4 months ago

liuyunnnn commented 4 months ago

Add execution id support.

When set LOG_EXECUTION_ID=True in environment variables or set --log-execution-id, execution id will be added to log along with trace and span id. Nodejs version 13.0.0 is required for feature above.

kenneth-rosario commented 4 months ago

I think you need to run npm run docs

liuyunnnn commented 4 months ago

Can we create integration test for this or would it be too complicated? similar to test/integration/http.ts . Not sure if we could redirect stdout to some sort of pipe and be able inspect the contents or make test function dump stdout on res.body. Let me know what you think.

I haven't figured out how to do that yet. All the ways I found are overriding console.log or process.stdout.write, which is the function we monkey patch in this PR.