Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = () => {
"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");
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`,
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);
/* 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';
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'
}
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!!!');
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`);
}