How to use the dd-trace.init 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 moleculerjs / moleculer / src / tracing / exporters / datadog2.js View on Github external
init(tracer) {
		super.init(tracer);

		try {
			const ddTrace = require("dd-trace");
			DatadogSpanContext = require("dd-trace/src/opentracing/span_context");
			DatadogPlatform = require("dd-trace/src/platform");
			this.ddTracer = global.tracer || ddTrace.init(_.defaultsDeep(this.opts.tracerOptions, {
				url: this.opts.agentUrl
			}));
		} catch(err) {
			/* istanbul ignore next */
			this.tracer.broker.fatal("The 'dd-trace' package is missing! Please install it with 'npm install dd-trace --save' command!", err, true);
		}

		this.defaultTags = _.isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags;
		if (this.defaultTags) {
			this.defaultTags = this.flattenTags(this.defaultTags, true);
		}

		this.ddScope = this.ddTracer.scope();

		const oldGetCurrentTraceID = this.tracer.getCurrentTraceID.bind(this.tracer);
		this.tracer.getCurrentTraceID = () => {
github moleculerjs / moleculer / dev / tracing.js View on Github external
"use strict";

const asyncHooks = require("async_hooks");

const tracer = require("dd-trace").init({
	service: "moleculer", // shows up as Service in Datadog UI
	//url: "http://192.168.0.181:8126",
	//debug: true,
	samplingPriority: "USER_KEEP",
});

tracer.use("http");
tracer.use("ioredis");


const ServiceBroker = require("../src/service-broker");
"use strict";

const { MoleculerError } 	= require("../src/errors");
const _ 					= require("lodash");
const { inspect }			= require("util");
github artsy / metaphysics / src / lib / tracer.ts View on Github external
export function init() {
  tracer.init({
    service: DD_TRACER_SERVICE_NAME,
    hostname: DD_TRACER_HOSTNAME,
    plugins: false,
    logger: { debug, error },
    debug: !PRODUCTION_ENV,
  })
  tracer.use("express", {
    // We want the root spans of MP to be labelled as just `metaphysics`
    service: DD_TRACER_SERVICE_NAME,
    headers: ["User-Agent", "X-User-ID"],
  } as any)
  tracer.use("http", {
    service: `${DD_TRACER_SERVICE_NAME}.http-client`,
  })
  tracer.use("graphql", {
    service: `${DD_TRACER_SERVICE_NAME}.graphql`,
github moleculerjs / moleculer / src / tracing / exporters / datadog.js View on Github external
init(tracer) {
		super.init(tracer);

		try {
			const ddTrace = require("dd-trace");
			DatadogSpanContext = require("dd-trace/packages/dd-trace/src/opentracing/span_context");
			DatadogID = require("dd-trace/packages/dd-trace/src/id");
			if (!this.ddTracer) {
				this.ddTracer = ddTrace.init(_.defaultsDeep(this.opts.tracerOptions, {
					url: this.opts.agentUrl
				}));
			}
		} catch(err) {
			/* istanbul ignore next */
			this.tracer.broker.fatal("The 'dd-trace' package is missing! Please install it with 'npm install dd-trace --save' command!", err, true);
		}

		this.defaultTags = _.isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags;
		if (this.defaultTags) {
			this.defaultTags = this.flattenTags(this.defaultTags, true);
		}

		this.ddScope = this.ddTracer.scope();

		const oldGetCurrentTraceID = this.tracer.getCurrentTraceID.bind(this.tracer);
github topcoder-platform / community-app / src / server / index.js View on Github external
/* eslint-disable */
/* Datadog debugging */
import ddTrace from 'dd-trace';

ddTrace.init();

import atob from 'atob';
import Application from 'shared';
import config from 'config';
import express from 'express';
import fetch from 'isomorphic-fetch';
import { logger } from 'topcoder-react-lib';
import fs from 'fs';
import moment from 'moment';
import path from 'path';
import qs from 'qs';
import serializeJs from 'serialize-javascript';

import { DoSSR } from 'utils/SSR';

import { factory as reducerFactory } from 'reducers';
github DefinitelyTyped / DefinitelyTyped / types / dd-trace / dd-trace-tests.ts View on Github external
import * as ddTrace from 'dd-trace';
import SpanContext = require('dd-trace/src/opentracing/span_context');

const tracer = ddTrace.init({
    service: 'MyLovelyService',
    hostname: 'localhost',
    port: 8126,
    logger: {
        debug: msg => { },
        error: err => { }
    }
});

tracer
    .trace('web.request', {
        service: 'my_service',
        childOf: new SpanContext({ traceId: 1337, spanId: 42 }),
        tags: {
            env: 'dev'
        }
github pagarme / escriba / examples / log-generator / index.js View on Github external
require('dotenv').config()
require('dd-trace').init()
const express = require('express')
const bodyParser = require('body-parser')
const cuid = require('cuid')
const { logger, httpLogger } = require('./lib/logger')
const logGenerator = require('./lib/log-generator')

const app = express()
app.use(bodyParser.json())
app.use(httpLogger)

app.post('/escriba', (req, res) => {
  res.send(`The body of your POST is: ${JSON.stringify(req.body)}`)
})

app.get('/escriba', (req, res) => {
  res.send('This is a log-generator example!!!');
github DataDog / datadog-lambda-layer-js / src / trace / datadog-tracer.ts View on Github external
export function initDatadogTracer() {
  const functionName = process.env[AWS_LAMBDA_FUNCTION_NAME];
  if (functionName === undefined) {
    logDebug(`Enviroment variable ${AWS_LAMBDA_FUNCTION_NAME} unavailable, using service name 'lambda'`);
  }
  const service = functionName ? `${functionName}` : "lambda";
  Tracer.init({
    experimental: {
      exporter: "log",
    },
    service,
  });
  logDebug(`Initialized datadog tracer for lambda`);
}