How to use the opentracing.Tracer function in opentracing

To help you get started, we’ve selected a few opentracing 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 sourcegraph / sourcegraph-typescript / src / extension / extension.ts View on Github external
// Cancel everything whene extension is deactivated
    const cancellationTokenSource = new CancellationTokenSource()
    ctx.subscriptions.add(() => cancellationTokenSource.cancel())
    const token = cancellationTokenSource.token

    const config = new BehaviorSubject(getConfig())
    ctx.subscriptions.add(sourcegraph.configuration.subscribe(() => config.next(getConfig())))

    const isLSIFAvailable = mkIsLSIFAvailable()
    const lsif = initLSIF()
    const basicCodeIntel = initBasicCodeIntel()

    const tracer: Tracer = config.value['lightstep.token']
        ? new LightstepTracer({ access_token: config.value['lightstep.token'], component_name: 'ext-lang-typescript' })
        : new Tracer()

    const accessToken = await getOrCreateAccessToken()
    /** The Sourcegraph endpoint contactable by the server */
    const serverSgEndpoint: SourcegraphEndpoint = {
        url: new URL(config.value['typescript.sourcegraphUrl'] || sourcegraph.internal.sourcegraphURL.toString()),
        accessToken,
    }
    /** The Sourcegraph endpoint contactable by the extension  */
    const clientSgEndpoint: SourcegraphEndpoint = {
        url: new URL(sourcegraph.internal.sourcegraphURL.toString()),
        accessToken,
    }

    const diagnosticsDecorationType = sourcegraph.app.createDecorationType()
    const codeActionsDecorationType = sourcegraph.app.createDecorationType()
github sourcegraph / sourcegraph-typescript / src / server / server.ts View on Github external
} from './resources'
import { sanitizeTsConfigs } from './tsconfig'
import { relativeUrl, URLMap, URLSet } from './uri'
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,
github RisingStack / opentracing-auto / src / instrumentation / httpClient.spec.js View on Github external
beforeEach(function () {
    tracer = new Tracer()
    mockChildSpan = {
      setTag: this.sandbox.spy(),
      log: this.sandbox.spy(),
      finish: this.sandbox.spy()
    }

    this.sandbox.stub(cls, 'startChildSpan').callsFake(() => mockChildSpan)
  })
github RisingStack / opentracing-auto / src / instrumentation / expressError.spec.js View on Github external
beforeEach(function () {
    tracer = new Tracer()
    mockRootSpan = {
      setTag: this.sandbox.spy()
    }
    mockChildSpan = {
      setTag: this.sandbox.spy(),
      log: this.sandbox.spy(),
      finish: this.sandbox.spy()
    }

    this.sandbox.stub(cls, 'getRootSpan').callsFake(() => mockRootSpan)
    this.sandbox.stub(cls, 'startChildSpan').callsFake(() => mockChildSpan)

    instrumentation.patch(express, [tracer])
  })
github RisingStack / opentracing-auto / src / instrumentation / mongodbCore.spec.js View on Github external
beforeEach(function (done) {
    tracer = new Tracer()
    mockChildSpan = {
      setTag: this.sandbox.spy(),
      log: this.sandbox.spy(),
      finish: this.sandbox.spy()
    }

    this.sandbox.stub(cls, 'startChildSpan').callsFake(() => mockChildSpan)

    instrumentation.patch(mongodbCore, [tracer])

    db = monk('localhost/mydb', done)
    dbSites = db.get('sites')
  })
github RisingStack / opentracing-auto / src / instrumentation / pg.spec.js View on Github external
beforeEach(function () {
    tracer = new Tracer()
    mockChildSpan = {
      setTag: this.sandbox.spy(),
      log: this.sandbox.spy(),
      finish: this.sandbox.spy()
    }

    this.sandbox.stub(cls, 'startChildSpan').callsFake(() => mockChildSpan)

    instrumentation.patch(pg, [tracer])

    db = knex({
      client: 'pg',
      connection: process.env.PG_URI
    })
  })
github sourcegraph / javascript-typescript-langserver / src / language-server.ts View on Github external
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))
github lightstep / lightstep-tracer-javascript / benchmarks / benchmark.js View on Github external
function createNoopTracer() {
    return new opentracing.Tracer();
}
function createNonReportingTracer() {
github RisingStack / opentracing-auto / src / instrumentation / redis.spec.js View on Github external
beforeEach(function () {
    tracer = new Tracer()
    mockChildSpan = {
      setTag: this.sandbox.spy(),
      log: this.sandbox.spy(),
      finish: this.sandbox.spy()
    }

    this.sandbox.stub(cls, 'startChildSpan').callsFake(() => mockChildSpan)

    instrumentation.patch(redis, [tracer])

    client = redis.createClient()
  })
github sourcegraph / sourcegraph-typescript / src / server / dependencies.ts View on Github external
export async function findClosestPackageJson(
    resource: URL,
    pickResourceRetriever: ResourceRetrieverPicker,
    rootUri = Object.assign(new URL(resource.href), { pathname: '' }),
    {
        span = new Span(),
        tracer = new Tracer(),
    }: {
        span?: Span
        tracer?: Tracer
    } = {}
): Promise<[URL, PackageJson]> {
    return await tracePromise(
        'Find closest package.json',
        tracer,
        span,
        async (span): Promise<[URL, PackageJson]> => {
            for (const parent of walkUp(resource)) {
                if (!parent.href.startsWith(rootUri.href)) {
                    break
                }
                const packageJsonUri = new URL('package.json', parent.href)
                try {