Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const packageJson = require('../package.json')
const program = require('commander')
const { initTracer } = require('jaeger-client')
program
.version(packageJson.version)
.option('-s, --strict', 'enables strict mode')
.option('-t, --trace', 'print all requests and responses')
.option('-l, --logfile [file]', 'log to this file')
.option('-j, --enable-jaeger', 'enable OpenTracing through Jaeger')
.parse(process.argv)
const logger = program.logfile ? new FileLogger(program.logfile) : new StderrLogger()
const tracer = program.enableJaeger
? initTracer({ serviceName: 'javascript-typescript-langserver', sampler: { type: 'const', param: 1 } })
: new Tracer()
const options: TypeScriptServiceOptions & MessageLogOptions & RegisterLanguageHandlerOptions = {
strict: program.strict,
logMessages: program.trace,
logger,
tracer,
}
const messageEmitter = new MessageEmitter(process.stdin, options)
const messageWriter = new MessageWriter(process.stdout, options)
const remoteClient = new RemoteLanguageClient(messageEmitter, messageWriter)
const service = new TypeScriptService(remoteClient, options)
// Add an exit notification handler to kill the process
messageEmitter.on('message', message => {
type: 'const',
param: 1,
},
reporter: {
collectorEndpoint: ingestUrl,
},
};
if (accessToken) {
// SignalFx supports Basic authentication with username "auth" and access token as password
config.reporter.username = 'auth'
config.reporter.password = accessToken
}
const options = { logger: console };
const tracer = initTracer(config, options);
// Register our tracer instance as the global tracer for easy access
// throughout Lambda function.
opentracing.initGlobalTracer(tracer);
return tracer;
}
type: 'const',
param: 1
},
reporter: {
agentHost: config.jaegerAgentHost,
agentPort: config.jaegerAgentPort,
logSpans: config.jaegerLogSpans
}
}
const tracerOptions = {
logger: options.logger, // https://github.com/jaegertracing/jaeger-client-node/blob/master/src/_flow/logger.js
metrics: options.metrics // https://github.com/jaegertracing/jaeger-client-node/blob/master/src/_flow/metrics.js
}
return initTracer(tracerConfig, tracerOptions)
}
import * as jaegerClient from "jaeger-client";
import * as promClient from "prom-client";
import * as opentracing from "opentracing";
const tracingConfig: jaegerClient.TracingConfig = {};
const tracingOptions: jaegerClient.TracingOptions = {};
const tracer = jaegerClient.initTracer(tracingConfig, tracingOptions);
jaegerClient.initTracerFromEnv(tracingConfig, tracingOptions);
const metrics = new jaegerClient.PrometheusMetricsFactory(promClient, "foo");
const textCodec = new jaegerClient.TextMapCodec({
contextKey: 'trace-id',
baggagePrefix: 'baggage-',
urlEncoding: false,
});
tracer.registerInjector(opentracing.FORMAT_TEXT_MAP, textCodec);
tracer.registerExtractor(opentracing.FORMAT_TEXT_MAP, textCodec);
const zipkinB3TextMapCodec = new jaegerClient.ZipkinB3TextMapCodec({
baggagePrefix: 'baggage-',
urlEncoding: false,
});
const contextKey = 'opentracing'
const tracingKey = 'opentracing'
const tracePrefix = 'Hemera'
const tags = {
HEMERA_PATTERN: 'hemera.pattern',
HEMERA_SERVICE: 'hemera.service',
HEMERA_ACT_TIMEOUT: 'hemera.act.timeout',
HEMERA_ACT_MAXMSG: 'hemera.act.maxMsg',
HEMERA_ACT_EXPECTEDMSG: 'hemera.act.expMsg',
HEMERA_PUBSUB: 'hemera.pubsub',
HEMERA_OP_TYPE: 'hemera.operationType',
HEMERA_CONTEXT: 'hemera.context'
}
const tracer = initTracer(opts.config, opts.options)
hemera.decorate('jaeger', {
tracer
})
hemera.ext('onError', (hemera, payload, error, next) => {
const span = hemera[jaegerContextKey]
span.setTag(Opentracing.Tags.ERROR, true)
span.log({
event: 'error',
'error.object': error,
message: error.message,
stack: error.stack
})
'number of concurrent cluster workers (defaults to number of CPUs, ' + numCPUs + ')',
parseInt
)
.option('-t, --trace', 'print all requests and responses')
.option('-l, --logfile [file]', 'log to this file')
.option('-j, --enable-jaeger', 'enable OpenTracing through Jaeger')
.parse(process.argv)
const options: ServeOptions & TypeScriptServiceOptions = {
clusterSize: program.cluster || numCPUs,
lspPort: program.port || defaultLspPort,
strict: program.strict,
logMessages: program.trace,
logger: program.logfile ? new FileLogger(program.logfile) : new StdioLogger(),
tracer: program.enableJaeger
? initTracer({ serviceName: 'javascript-typescript-langserver', sampler: { type: 'const', param: 1 } })
: new Tracer(),
}
serve(options, client => new TypeScriptService(client, options))
const options = {
logger: {
info(msg) {
log('info', {
payload: msg
});
},
error(msg) {
log('error', {
payload: msg
});
}
}
};
global['tracer'] = initJaegerTracer(tracerConfig, options);
let parentSpan;
if (Object.keys(headers).length === 0) {
parentSpan = global['tracer'].startSpan(projectName);
} else {
const parentSpanContext = global['tracer'].extract(
FORMAT_HTTP_HEADERS,
headers
);
parentSpan = global['tracer'].startSpan(projectName, {
childOf: parentSpanContext
});
}
sampler: {
type: 'const',
param: 1,
host: 'localhost',
port: '5775',
refreshIntervalMs: 500
}
}
const options = {
tags: {
'my-awesome-service.version': '1.1.2'
},
metrics: null,
logger: null
}
const tracer = initTracer(config, options)
const parentSpan = tracer.startSpan('test')
parentSpan.addTags({ level: 0 })
const child = tracer.startSpan('child_span', { childOf: parentSpan })
child.setTag('alpha', '200')
child.setTag('beta', '50')
child.log({state: 'waiting'})
setTimeout(() => {
child.log({state: 'done'})
child.finish()
parentSpan.finish()
tracer.close()
}, 500)