|
| 1 | +# Tracing |
| 2 | + |
| 3 | + Stability: 1 - Experimental |
| 4 | + |
| 5 | +The tracing module is designed for instrumenting your Node application. It is |
| 6 | +not meant for general purpose use. |
| 7 | + |
| 8 | +***Be very careful with callbacks used in conjunction with this module*** |
| 9 | + |
| 10 | +Many of these callbacks interact directly with asynchronous subsystems in a |
| 11 | +synchronous fashion. That is to say, you may be in a callback where a call to |
| 12 | +`console.log()` could result in an infinite recursive loop. Also of note, many |
| 13 | +of these callbacks are in hot execution code paths. That is to say your |
| 14 | +callbacks are executed quite often in the normal operation of Node, so be wary |
| 15 | +of doing CPU bound or synchronous workloads in these functions. Consider a ring |
| 16 | +buffer and a timer to defer processing. |
| 17 | + |
| 18 | +`require('tracing')` to use this module. |
| 19 | + |
| 20 | +## v8 |
| 21 | + |
| 22 | +The `v8` property is an [EventEmitter][], it exposes events and interfaces |
| 23 | +specific to the version of `v8` built with node. These interfaces are subject |
| 24 | +to change by upstream and are therefore not covered under the stability index. |
| 25 | + |
| 26 | +### Event: 'gc' |
| 27 | + |
| 28 | +`function (before, after) { }` |
| 29 | + |
| 30 | +Emitted each time a GC run is completed. |
| 31 | + |
| 32 | +`before` and `after` are objects with the following properties: |
| 33 | + |
| 34 | +``` |
| 35 | +{ |
| 36 | + type: 'mark-sweep-compact', |
| 37 | + flags: 0, |
| 38 | + timestamp: 905535650119053, |
| 39 | + total_heap_size: 6295040, |
| 40 | + total_heap_size_executable: 4194304, |
| 41 | + total_physical_size: 6295040, |
| 42 | + used_heap_size: 2855416, |
| 43 | + heap_size_limit: 1535115264 |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +### getHeapStatistics() |
| 48 | + |
| 49 | +Returns an object with the following properties |
| 50 | + |
| 51 | +``` |
| 52 | +{ |
| 53 | + total_heap_size: 7326976, |
| 54 | + total_heap_size_executable: 4194304, |
| 55 | + total_physical_size: 7326976, |
| 56 | + used_heap_size: 3476208, |
| 57 | + heap_size_limit: 1535115264 |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +[EventEmitter]: events.html#events_class_events_eventemitter |
0 commit comments