How to use the dd-trace.scopeManager function in dd-trace

To help you get started, we’ve selected a few dd-trace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nathanpeck / socket.io-chat-fargate / services / message-cards / index.js View on Github external
poller.on('message', function(msg) {
  const span = tracer.startSpan('message');
  span.setTag('service.name', 'message-cards');
  span.setTag('resource.name', 'message');
  tracer.scopeManager().activate(span);

  console.log(JSON.stringify(msg.body));

  msg.del();
  span.finish();
});
github artsy / metaphysics / src / lib / tracer.ts View on Github external
const createCommand = (command: string) => <T>(
  promise: Promise<T>
): Promise<T> => {
  const parentScope = tracer.scopeManager().active()
  const span = tracer.startSpan("memcached", {
    childOf: parentScope && parentScope.span(),
    tags: {
      [Tags.SPAN_KIND]: Tags.SPAN_KIND_RPC_CLIENT,
      [Tags.DB_TYPE]: "memcached",
      "service.name": `${DD_TRACER_SERVICE_NAME}.memcached`,
      "resource.name": command,
      "span.type": "memcached",
    },
  })

  return promise.then(
    result => {
      span.finish()
      return result
    },