Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.js Interactive Europe 2016: Tracing and in...

Thomas Watson
September 15, 2016

Node.js Interactive Europe 2016: Tracing and instrumentation in Node.js

This talk is a head first dive into the next-gen core tracing API’s being developed under the Node.js Tracing Working Group. We’ll learn about the upcoming AsyncWrap API and how this can be used to build your own high level instrumentation logic in production.

Thomas Watson

September 15, 2016
Tweet

More Decks by Thomas Watson

Other Decks in Programming

Transcript

  1. Patch the world • Patch every async operation in core

    • timers • process.nextTick • Promise (native) • libuv • Patch certain 3rd party modules @wa7son
  2. user: before async_hooks: init user: after async_hooks: pre user: done

    async_hooks: post async_hooks: destroy @wa7son
  3. user: before async_hooks: init user: after async_hooks: pre user: done

    async_hooks: post async_hooks: destroy @wa7son
  4. > var asyncWrap = process.binding('async_wrap') undefined > asyncWrap.Providers { NONE:

    0, CRYPTO: 1, FSEVENTWRAP: 2, FSREQWRAP: 3, GETADDRINFOREQWRAP: 4, GETNAMEINFOREQWRAP: 5, HTTPPARSER: 6, JSSTREAM: 7, PIPEWRAP: 8, PIPECONNECTWRAP: 9, PROCESSWRAP: 10, QUERYWRAP: 11, SHUTDOWNWRAP: 12, SIGNALWRAP: 13, STATWATCHER: 14, TCPWRAP: 15, TCPCONNECTWRAP: 16, TIMERWRAP: 17, TLSWRAP: 18, TTYWRAP: 19, UDPWRAP: 20, UDPSENDWRAP: 21, WRITEWRAP: 22, ZLIB: 23 } @wa7son
  5. Timers user: before #1 async_hooks: init user: after #1 user:

    before #2 user: after #2 async_hooks: pre user: done #1 user: done #2 async_hooks: post async_hooks: destroy @wa7son
  6. AsyncHooks Gotchas • Handle creation time • console.log • (process.nextTick)

    • Timers • Promises • Multiple AsyncHooks @wa7son