googleapis / cloud-trace-nodejs

Node.js agent for Cloud Trace: automatically gather latency data about your application
https://cloud.google.com/trace/
Apache License 2.0
280 stars 98 forks source link

Koa deprecated Support for generators #664

Closed henryoliver closed 6 years ago

henryoliver commented 6 years ago

Hey guys!

I'm a paid user for the Google cloud platform and love it.

Could you guys please update the driver for koajs? I start to get the following warning:

Mon, 05 Feb 2018 11:47:29 GMT koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md at node_modules/@google-cloud/trace-agent/build/src/plugins/plugin-koa.js:99:24

You guys can follow the update instructions here, I think it will be pretty straightforward: https://github.com/koajs/koa/blob/master/docs/migration.md

Thank you for your awesome job in this library! Henry

kjin commented 6 years ago

The Trace Agent doesn't prepend generator functions for Koa 2. I think what's happening is that the warning message shows the top line of the stack trace when Koa#use is being called. Because the Trace Agent wraps this function, it altered the stack trace to add an extra frame to the top as you've observed.

I would expect that when turning off the Trace Agent (by removing the call to start), the warning message will show a line in your application where a generator is still being used.

Let us know if this solves the issue!

henryoliver commented 6 years ago

Hi @kjin thanks for your explanation, really appreciate that! But, could you be a little bit more detailed? How could I start the monitor in my Koa2 application without getting this warning? Any code example would be very helpful.

Below is how I currently call the monitor in my application:

// Stackdriver
const trace = require('@google-cloud/trace-agent').start({
    projectId: 'polen--project',
    serviceContext: {
        service: 'glasstone-travel-channel',
        version: '1.0.0'
    }
});

Getting the message: koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md node_modules/@google-cloud/trace-agent/build/src/plugins/plugin-koa.js:99:24

Thanks!

kjin commented 6 years ago

Sure, what I mean is that I suspect you will get a warning even if you comment out the code above. Here's a code example: https://gist.github.com/kjin/e1b9ddcf4360adbdef2e11b939d6a6f2

henryoliver commented 6 years ago

Can I use the agent without a generator function, since I'm using Koa2? Thanks

kjin commented 6 years ago

Yes, you can! The example shown was just for the sake of showing how the warning changes depending on whether the Trace Agent is started or not.

kjin commented 6 years ago

@henryoliver Were you able to verify whether the warning message comes from use of generators external to the Trace Agent?

kjin commented 6 years ago

@henryoliver Closing this for now. Please comment if this doesn't work for you.