How to use the jaeger-client.ConstSampler function in jaeger-client

To help you get started, we’ve selected a few jaeger-client 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 RisingStack / opentracing-auto / example / server2.js View on Github external
'use strict'

const jaeger = require('jaeger-client')
const UDPSender = require('jaeger-client/dist/src/reporters/udp_sender').default
// eslint-disable-next-line
const Instrument = require('../src')

const sampler = new jaeger.ConstSampler(true)
const reporter = new jaeger.RemoteReporter(new UDPSender())
const tracer = new jaeger.Tracer('my-server-2', reporter, sampler, {
  tags: {
    gitTag: 'bar'
  }
})
// eslint-disable-next-line
const instrument = new Instrument({
  tracers: [tracer],
  httpTimings: true
})

const express = require('express')
const request = require('request-promise-native')
const monk = require('monk')
github RisingStack / opentracing-auto / example / server1.js View on Github external
'use strict'

const jaeger = require('jaeger-client')
const UDPSender = require('jaeger-client/dist/src/reporters/udp_sender').default
// eslint-disable-next-line
const Instrument = require('../src')

const sampler = new jaeger.ConstSampler(true)
const reporter = new jaeger.RemoteReporter(new UDPSender())
const tracer = new jaeger.Tracer('my-server-1', reporter, sampler, {
  tags: {
    gitTag: 'foo'
  }
})
// eslint-disable-next-line
const instrument = new Instrument({
  tracers: [tracer],
  httpTimings: true
})

// eslint-disable-next-line
const http = require('http')
// eslint-disable-next-line
const express = require('express')
github RisingStack / opentracing-auto / example / server-pg.js View on Github external
'use strict'

const jaeger = require('jaeger-client')
const UDPSender = require('jaeger-client/dist/src/reporters/udp_sender').default
// eslint-disable-next-line
const Instrument = require('../src')

const sampler = new jaeger.ConstSampler(true)
const reporter = new jaeger.RemoteReporter(new UDPSender())
const tracer = new jaeger.Tracer('my-server-pg', reporter, sampler, {
  tags: {
    gitTag: 'foobar'
  }
})
// eslint-disable-next-line
const instrument = new Instrument({ tracers: [tracer] })

const knex = require('knex')
const express = require('express')

// postgres config
const pgUser = process.env.PG_USER || process.env.USER || 'root'
const pgPw = process.env.PG_PASSWORD || ''
const pgDB = process.env.PG_DATABASE || 'postgres'
github sematext / opentracing-materials / nodejs / index.js View on Github external
const serviceName = "octi";
const options = {
    tags: {
      'api-token': ''
    }
};

const httpOpts = {
    host : 'localhost',
    method: 'GET',
    port : '3000',
    path: '/',
};

var reporter = new jaeger.RemoteReporter(new UDPSender());
var sampler = new jaeger.ConstSampler(1);
var tracer = new jaeger.Tracer(serviceName, reporter, sampler, options);

const span = tracer.startSpan('http-request');

http.request(httpOpts, res => {
    res.setEncoding('utf8');
    res.on('error', err => {
        span.setTag(opentracing.Tags.ERROR, true);
        span.log({'event': 'error', 'error.object': err, 'message': err.message, 'stack': err.stack});
        span.finish();
    });
    res.on('data', chunk => {
        span.log({'event': 'data_received', 'chunk_length': chunk.length});
    });
    res.on('end', () => {
        span.log({'event': 'request_end'});
github moleculerjs / moleculer-metrics / packages / moleculer-jaeger / src / index.js View on Github external
if (isFunction(this.settings.sampler))
				return this.settings.sampler;

			if (this.settings.sampler.type == "RateLimiting")
				return new Jaeger.RateLimitingSampler(this.settings.sampler.options.maxTracesPerSecond, this.settings.sampler.options.initBalance);

			if (this.settings.sampler.type == "Probabilistic")
				return new Jaeger.ProbabilisticSampler(this.settings.sampler.options.samplingRate);

			if (this.settings.sampler.type == "GuaranteedThroughput")
				return new GuaranteedThroughputSampler(this.settings.sampler.options.lowerBound, this.settings.sampler.options.samplingRate);

			if (this.settings.sampler.type == "RemoteControlled")
				return new RemoteControlledSampler(serviceName, this.settings.sampler.options);

			return new Jaeger.ConstSampler(this.settings.sampler.options && this.settings.sampler.options.decision != null ? this.settings.sampler.options.decision : 1);
		},