Created
December 1, 2012 15:48
-
-
Save chrisa/4182961 to your computer and use it in GitHub Desktop.
Objects-as-JSON with Node dtrace-provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [chris@1c89eadf-3091-4306-ac1b-a75c3050ca29 ~/node-dtrace-provider]$ sudo /usr/sbin/dtrace -Z -s json.d -c 'node jsonargs.js' | |
| dtrace: script 'json.d' matched 0 probes | |
| dtrace: pid 9006 has exited | |
| CPU ID FUNCTION:NAME | |
| 0 62731 json1:json1 json: {"foo":42,"bar":"forty-two"} | |
| 0 62731 json1:json1 int: 42 string: forty-two |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nodeapp$target:::json1 { | |
| this->j = copyinstr(arg0); | |
| printf("json: %s ", this->j); | |
| } | |
| nodeapp$target:::json1 { | |
| this->j = copyinstr(arg0); | |
| printf("int: %d ", strtoll(json(this->j, "foo"))); | |
| printf("string: %s", json(this->j, "bar")); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var d = require('../dtrace-provider'); | |
| var provider = d.createDTraceProvider("nodeapp"); | |
| var probe = provider.addProbe("json1", "json"); | |
| provider.enable(); | |
| var obj = new Object; | |
| obj.foo = 42; | |
| obj.bar = 'forty-two'; | |
| probe.fire(function(p) { | |
| return [obj]; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment