Created
November 11, 2020 23:09
-
-
Save tedsuo/969dcea3e3c239d7ebe33aa6cc47f375 to your computer and use it in GitHub Desktop.
node_span_basics.js
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
| const app = express(); | |
| app.get('/hello', (req, res) => { | |
| // access the span created by express instrumentation | |
| span = tracer.getCurrentSpan(); | |
| // add an attribute to segment your data by projectID | |
| span.setAttribute('projectID', '123'); | |
| // log an event and include some structured data. | |
| span.addEvent('setting timeout', { sleep: 300 }); | |
| setTimeout(()=> { | |
| span.addEvent(responding after timeout); | |
| res.status(200).send('Hello World'); | |
| }, 300); | |
| }); | |
| app.listen(9000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment