Skip to content

Instantly share code, notes, and snippets.

@tedsuo
Created November 11, 2020 23:09
Show Gist options
  • Select an option

  • Save tedsuo/969dcea3e3c239d7ebe33aa6cc47f375 to your computer and use it in GitHub Desktop.

Select an option

Save tedsuo/969dcea3e3c239d7ebe33aa6cc47f375 to your computer and use it in GitHub Desktop.
node_span_basics.js
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