Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("works with latest lightstep tracer", (done) => {
const lsTracer = new LightStep.Tracer({
access_token : 'foo',
component_name : 'bar',
});
const app = express();
app.use(middleware({tracer: lsTracer}));
var reqSpanPresent = false;
app.get("/", (req, res) => {
if (req.span) {
reqSpanPresent = true;
}
res.send("Hello World!")
});
const server = app.listen(3000, (err) => {
const opts = {
if (typeof program.data_root === 'undefined') {
winston.error('no data_root given!');
process.exit(1);
}
if (typeof program.access_token === 'undefined') {
winston.error('no access_token given!');
process.exit(1);
}
const databasePath = path.join(program.data_root, common.databaseName);
const imageRoot = path.join(program.data_root, '/images/');
const accessToken = program.access_token;
const tracer = new lightstep.Tracer(
{ access_token: accessToken, component_name: 'zoo' });
opentracing.initGlobalTracer(tracer);
const db = new sqlite3.Database(databasePath);
db.run('PRAGMA journal_mode = WAL');
db.configure('busyTimeout', 15000);
function onExit() {
db.close();
process.exit(0);
}
process.on('SIGINT', onExit);
process.on('SIGTERM', onExit);
const app = express();
app.use(tracingMiddleware.middleware({ tracer }));
import { install } from './yarn'
const globalLogger = new RedactingLogger(console)
process.on('uncaughtException', err => {
globalLogger.error('Uncaught exception:', err)
process.exit(1)
})
const CACHE_DIR = process.env.CACHE_DIR || fs.realpathSync(tmpdir())
globalLogger.log(`Using CACHE_DIR ${CACHE_DIR}`)
let tracer = new Tracer()
if (process.env.LIGHTSTEP_ACCESS_TOKEN) {
globalLogger.log('LightStep tracing enabled')
tracer = new LightstepTracer({
access_token: process.env.LIGHTSTEP_ACCESS_TOKEN,
component_name: 'lang-typescript',
})
}
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 8080
let httpServer: http.Server | https.Server
if (process.env.TLS_CERT && process.env.TLS_KEY) {
globalLogger.log('TLS encryption enabled')
httpServer = https.createServer({
cert: process.env.TLS_CERT,
key: process.env.TLS_KEY,
})
} else {
httpServer = http.createServer()
}
): Tracer | undefined {
if (useJaeger) {
const config = {
serviceName,
sampler: {
type: 'const',
param: 1,
},
}
return initTracerFromEnv(config, {})
}
if (lightstepAccessToken !== '') {
return new lightstep.Tracer({
access_token: lightstepAccessToken,
component_name: serviceName,
})
}
return undefined
}
agentHost: env.TRACE_AGENT_HOST,
agentPort: env.TRACE_AGENT_PORT,
},
sampler: {
type: 'const',
param: 1,
}
};
const options = { logger: agent.logger };
const tracer = jaegerClient.initTracer(config, options);
return tracer;
}
if (env.TRACE_AGENT_CLIENT === constants.TRACER_LIGHTSTEP) {
const lightstepClient = require('lightstep-tracer');
const tracer = new lightstepClient.Tracer({
access_token: env.TRACE_AGENT_API_KEY,
component_name: serviceName
});
return tracer;
}
return stubs.tracer;
};