def __init__(self, channel=None, batch_size=10): super(UDPSender, self).__init__(batch_size=batch_size) self._channel = channel or self._create_local_agent_channel() self._host = self._channel._host self._port = self._channel._reporting_port self._agent = Agent.Client(self.getProtocol(self._channel)) self._max_span_space = None
def __init__(self, channel, queue_capacity=100, batch_size=10, flush_interval=DEFAULT_FLUSH_INTERVAL, io_loop=None, error_reporter=None, metrics=None, metrics_factory=None, **kwargs): """ :param channel: a communication channel to jaeger-agent :param queue_capacity: how many spans we can hold in memory before starting to drop spans :param batch_size: how many spans we can submit at once to Collector :param flush_interval: how often the auto-flush is called (in seconds) :param io_loop: which IOLoop to use. If None, try to get it from channel (only works if channel is tchannel.sync) :param error_reporter: :param metrics: an instance of Metrics class, or None. This parameter has been deprecated, please use metrics_factory instead. :param metrics_factory: an instance of MetricsFactory class, or None. :param kwargs: 'logger' :return: """ from threading import Lock self._channel = channel self.queue_capacity = queue_capacity self.batch_size = batch_size self.metrics_factory = metrics_factory or LegacyMetricsFactory( metrics or Metrics()) self.metrics = ReporterMetrics(self.metrics_factory) self.error_reporter = error_reporter or ErrorReporter(Metrics()) self.logger = kwargs.get('logger', default_logger) self.agent = Agent.Client(self._channel, self) if queue_capacity < batch_size: raise ValueError('Queue capacity cannot be less than batch size') self.io_loop = io_loop or channel.io_loop if self.io_loop is None: self.logger.error('Jaeger Reporter has no IOLoop') else: self.queue = tornado.queues.Queue(maxsize=queue_capacity) self.stop = object() self.stopped = False self.stop_lock = Lock() self.flush_interval = flush_interval or None self.io_loop.spawn_callback(self._consume_queue) self._process_lock = Lock() self._process = None
def serialize(span_id): parent = Span(trace_id=span_id, span_id=span_id, parent_id=0, flags=1, operation_name='x', tracer=tracer) span = tracer.start_span(operation_name='x', parent=parent) span.finish() spans = thrift.make_zipkin_spans([span]) # write and read them to test encoding args = Agent.emitZipkinBatch_args(spans) t = TestTrans() prot = TCompactProtocol(t) args.write(prot) t.now_reading() args.read(prot)
def _marshall_span(span): class TestTrans(TMemoryBuffer): def now_reading(self): """ Thrift TMemoryBuffer is not read-able AND write-able, it's one or the other (really? yes.). This will convert us from write-able to read-able. """ self._buffer = BytesIO(self.getvalue()) spans = thrift.make_zipkin_spans([span]) # write and read them to test encoding args = Agent.emitZipkinBatch_args(spans) t = TestTrans() prot = TCompactProtocol(t) args.write(prot) t.now_reading() args.read(prot)
def _marshall_span(span): class TestTrans(TMemoryBuffer): def now_reading(self): """ Thrift TMemoryBuffer is not read-able AND write-able, it's one or the other (really? yes.). This will convert us from write-able to read-able. """ self._buffer = BytesIO(self.getvalue()) batch = thrift.make_jaeger_batch( spans=[span], process=ttypes.Process(serviceName='x', tags={})) # write and read them to test encoding args = Agent.emitBatch_args(batch) t = TestTrans() prot = TCompactProtocol(t) args.write(prot) t.now_reading() args.read(prot)
def __init__(self, host, port, io_loop=None): super(UDPSender, self).__init__(host=host, port=port, io_loop=io_loop) self.channel = self._create_local_agent_channel(self.io_loop) self.agent = Agent.Client(self.channel, self)
def __init__(self, channel, batch_size=1): self._channel = channel self._batch_size = batch_size self._spans = [] self.agent = Agent.Client(self._channel, self) self._process = None