diff --git a/.travis.yml b/.travis.yml index 094e69f7..790ffea3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ matrix: env: COVER=1 - python: '2.7' env: CROSSDOCK=1 + - python: '3.6' + env: COVER=1 + - python: '3.6' + env: CROSSDOCK=1 services: - docker diff --git a/Makefile b/Makefile index 74db86bc..debd33fe 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ shell: # Generate jaeger thrifts THRIFT_GEN_DIR=jaeger_client/thrift_gen -THRIFT_VER=0.9.3 +THRIFT_VER=0.10.0 THRIFT_IMG=thrift:$(THRIFT_VER) THRIFT_PY_ARGS=new_style,tornado THRIFT=docker run -v "${PWD}:/data" $(THRIFT_IMG) thrift diff --git a/crossdock/server/endtoend.py b/crossdock/server/endtoend.py index 88c9b296..bbab8cf3 100644 --- a/crossdock/server/endtoend.py +++ b/crossdock/server/endtoend.py @@ -1,5 +1,8 @@ +from builtins import range +from builtins import object import tornado.web import json +import six from jaeger_client.local_agent_net import LocalAgentSender from jaeger_client.config import ( @@ -99,7 +102,7 @@ def generate_traces(self, request, response_writer): tracer = self.tracers[sampler_type] for _ in range(req.get('count', 0)): span = tracer.start_span(req['operation']) - for k, v in req.get('tags', {}).iteritems(): + for k, v in six.iteritems(req.get('tags', {})): span.set_tag(k, v) span.finish() response_writer.finish() diff --git a/crossdock/server/serializer.py b/crossdock/server/serializer.py index 49755eb5..a583e38d 100644 --- a/crossdock/server/serializer.py +++ b/crossdock/server/serializer.py @@ -1,5 +1,7 @@ +from builtins import str import json import logging +import six from crossdock.thrift_gen.tracetest.ttypes import JoinTraceRequest, StartTraceRequest, \ Downstream, Transport, TraceResponse, ObservedSpan @@ -93,7 +95,7 @@ def traced_service_object_to_json(obj): def set_traced_service_object_values(obj, values, downstream_func): - for k in values.iterkeys(): + for k in six.iterkeys(values): if hasattr(obj, k): if k == 'downstream': if values[k] is not None: diff --git a/crossdock/server/server.py b/crossdock/server/server.py index 7b1e4137..3b7fae00 100644 --- a/crossdock/server/server.py +++ b/crossdock/server/server.py @@ -1,3 +1,4 @@ +from builtins import object import logging import tornado.web diff --git a/jaeger_client/codecs.py b/jaeger_client/codecs.py index d25eb69e..97983bc0 100644 --- a/jaeger_client/codecs.py +++ b/jaeger_client/codecs.py @@ -19,8 +19,13 @@ # THE SOFTWARE. from __future__ import absolute_import +from future import standard_library +standard_library.install_aliases() +from past.builtins import basestring +from builtins import object -import urllib +import urllib.request, urllib.parse, urllib.error +import six from opentracing import ( InvalidCarrierException, @@ -64,29 +69,29 @@ def inject(self, span_context, carrier): parent_id=span_context.parent_id, flags=span_context.flags) baggage = span_context.baggage if baggage: - for key, value in baggage.iteritems(): + for key, value in six.iteritems(baggage): if self.url_encoding: - encoded_value = urllib.quote(value) + encoded_value = urllib.parse.quote(value) else: encoded_value = value carrier['%s%s' % (self.baggage_prefix, key)] = encoded_value def extract(self, carrier): - if not hasattr(carrier, 'iteritems'): + if not isinstance(carrier, dict): raise InvalidCarrierException('carrier not a collection') trace_id, span_id, parent_id, flags = None, None, None, None baggage = None debug_id = None - for key, value in carrier.iteritems(): + for key, value in six.iteritems(carrier): uc_key = key.lower() if uc_key == self.trace_id_header: if self.url_encoding: - value = urllib.unquote(value) + value = urllib.parse.unquote(value) trace_id, span_id, parent_id, flags = \ span_context_from_string(value) elif uc_key.startswith(self.baggage_prefix): if self.url_encoding: - value = urllib.unquote(value) + value = urllib.parse.unquote(value) attr_key = key[self.prefix_length:] if baggage is None: baggage = {attr_key.lower(): value} @@ -94,7 +99,7 @@ def extract(self, carrier): baggage[attr_key.lower()] = value elif uc_key == self.debug_id_header: if self.url_encoding: - value = urllib.unquote(value) + value = urllib.parse.unquote(value) debug_id = value if not trace_id and baggage: raise SpanContextCorruptedException('baggage without trace ctx') @@ -137,7 +142,7 @@ def span_context_to_string(trace_id, span_id, parent_id, flags): :param parent_id: :param flags: """ - parent_id = parent_id or 0L + parent_id = parent_id or 0 return '{:x}:{:x}:{:x}:{:x}'.format(trace_id, span_id, parent_id, flags) @@ -162,9 +167,9 @@ def span_context_from_string(value): raise SpanContextCorruptedException( 'malformed trace context "%s"' % value) try: - trace_id = long(parts[0], 16) - span_id = long(parts[1], 16) - parent_id = long(parts[2], 16) + trace_id = int(parts[0], 16) + span_id = int(parts[1], 16) + parent_id = int(parts[2], 16) flags = int(parts[3], 16) if trace_id < 1 or span_id < 1 or parent_id < 0 or flags < 0: raise SpanContextCorruptedException( diff --git a/jaeger_client/config.py b/jaeger_client/config.py index 3f2cf53a..59514858 100644 --- a/jaeger_client/config.py +++ b/jaeger_client/config.py @@ -19,6 +19,7 @@ # THE SOFTWARE. from __future__ import absolute_import +from builtins import object import logging import threading diff --git a/jaeger_client/constants.py b/jaeger_client/constants.py index fa53decf..ae18fe87 100644 --- a/jaeger_client/constants.py +++ b/jaeger_client/constants.py @@ -33,10 +33,10 @@ DEFAULT_FLUSH_INTERVAL = 1 # Name of the HTTP header used to encode trace ID -TRACE_ID_HEADER = b'uber-trace-id' +TRACE_ID_HEADER = 'uber-trace-id' # Prefix for HTTP headers used to record baggage items -BAGGAGE_HEADER_PREFIX = b'uberctx-' +BAGGAGE_HEADER_PREFIX = 'uberctx-' # The name of HTTP header or a TextMap carrier key which, if found in the # carrier, forces the trace to be sampled as "debug" trace. The value of the diff --git a/jaeger_client/local_agent_net.py b/jaeger_client/local_agent_net.py index 82fbe69a..de4349ec 100644 --- a/jaeger_client/local_agent_net.py +++ b/jaeger_client/local_agent_net.py @@ -19,6 +19,7 @@ # THE SOFTWARE. from __future__ import absolute_import +from builtins import object from threadloop import ThreadLoop import tornado import tornado.httpclient diff --git a/jaeger_client/metrics.py b/jaeger_client/metrics.py index 1b727526..b424b697 100644 --- a/jaeger_client/metrics.py +++ b/jaeger_client/metrics.py @@ -19,6 +19,7 @@ # THE SOFTWARE. from __future__ import absolute_import +from builtins import object class Metrics(object): diff --git a/jaeger_client/rate_limiter.py b/jaeger_client/rate_limiter.py index dd1b155f..1b4da05b 100644 --- a/jaeger_client/rate_limiter.py +++ b/jaeger_client/rate_limiter.py @@ -1,3 +1,4 @@ +from builtins import object # Copyright (c) 2017 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/jaeger_client/reporter.py b/jaeger_client/reporter.py index 70c04b05..538b31db 100644 --- a/jaeger_client/reporter.py +++ b/jaeger_client/reporter.py @@ -19,6 +19,7 @@ # THE SOFTWARE. from __future__ import absolute_import +from builtins import object import logging import threading diff --git a/jaeger_client/sampler.py b/jaeger_client/sampler.py index 8e8b2f18..39705d89 100644 --- a/jaeger_client/sampler.py +++ b/jaeger_client/sampler.py @@ -19,9 +19,13 @@ # THE SOFTWARE. from __future__ import absolute_import +from __future__ import division +from builtins import object +from past.utils import old_div import logging import random import json +import six from threading import Lock from tornado.ioloop import PeriodicCallback @@ -45,7 +49,7 @@ SAMPLER_TYPE_TAG_KEY = 'sampler.type' SAMPLER_PARAM_TAG_KEY = 'sampler.param' DEFAULT_SAMPLING_PROBABILITY = 0.001 -DEFAULT_LOWER_BOUND = 1.0 / (10.0 * 60.0) # sample once every 10 minutes +DEFAULT_LOWER_BOUND = old_div(1.0, (10.0 * 60.0)) # sample once every 10 minutes DEFAULT_MAX_OPERATIONS = 2000 STRATEGIES_STR = 'perOperationStrategies' @@ -235,7 +239,7 @@ def update(self, lower_bound, rate): def __str__(self): return 'GuaranteedThroughputProbabilisticSampler(%s, %s, %s)' \ - % (self.operation, self.rate, self.lower_bound) + % (self.operation, self.rate, round(float(self.lower_bound), 14)) class AdaptiveSampler(Sampler): @@ -306,12 +310,12 @@ def update(self, strategies): ProbabilisticSampler(self.default_sampling_probability) def close(self): - for _, sampler in self.samplers.iteritems(): + for _, sampler in six.iteritems(self.samplers): sampler.close() def __str__(self): return 'AdaptiveSampler(%s, %s, %s)' \ - % (self.default_sampling_probability, self.lower_bound, + % (self.default_sampling_probability, round(float(self.lower_bound), 14), self.max_operations) diff --git a/jaeger_client/span.py b/jaeger_client/span.py index 385dbb43..d3ad7ad0 100644 --- a/jaeger_client/span.py +++ b/jaeger_client/span.py @@ -19,10 +19,12 @@ # THE SOFTWARE. from __future__ import absolute_import +from builtins import str import json import threading import time +import six import opentracing from opentracing.ext import tags as ext_tags @@ -54,7 +56,7 @@ def __init__(self, context, tracer, operation_name, self.tags = [] self.logs = [] if tags: - for k, v in tags.iteritems(): + for k, v in six.iteritems(tags): self.set_tag(k, v) def set_operation_name(self, operation_name): diff --git a/jaeger_client/thrift.py b/jaeger_client/thrift.py index 878bd5c9..b4eb0af1 100644 --- a/jaeger_client/thrift.py +++ b/jaeger_client/thrift.py @@ -1,3 +1,4 @@ +from past.builtins import basestring # Copyright (c) 2016 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -20,6 +21,7 @@ import socket import struct +import sys import jaeger_client.thrift_gen.zipkincore.ZipkinCollector as zipkin_collector import jaeger_client.thrift_gen.sampling.SamplingManager as sampling_manager @@ -30,8 +32,12 @@ _max_signed_port = (1 << 15) - 1 _max_unsigned_port = (1 << 16) -_max_signed_id = (1L << 63) - 1 -_max_unsigned_id = (1L << 64) +_max_signed_id = (1 << 63) - 1 +_max_unsigned_id = (1 << 64) + + +def str_to_binary(value): + return value if sys.version_info[0] == 2 else value.encode('utf-8') def ipv4_to_int(ipv4): @@ -61,6 +67,12 @@ def port_to_int(port): def id_to_int(big_id): # zipkincore.thrift defines ID fields as i64, which is signed, # therefore we convert large IDs (> 2^63) to negative longs + + # In Python 2, expression None > 1 is legal and has a value of False + # In Python 3, this expression is illegal - so we need to have an additional check + if big_id is None: + return None + if big_id > _max_signed_id: big_id -= _max_unsigned_id return big_id @@ -78,8 +90,9 @@ def make_endpoint(ipv4, port, service_name): def make_string_tag(key, value): if len(value) > 256: value = value[:256] + return zipkin_collector.BinaryAnnotation( - key, value, zipkin_collector.AnnotationType.STRING) + key, str_to_binary(value), zipkin_collector.AnnotationType.STRING) def make_peer_address_tag(key, host): @@ -90,7 +103,7 @@ def make_peer_address_tag(key, host): :param host: """ return zipkin_collector.BinaryAnnotation( - key, '0x01', zipkin_collector.AnnotationType.BOOL, host) + key, str_to_binary('0x01'), zipkin_collector.AnnotationType.BOOL, host) def make_local_component_tag(component_name, endpoint): @@ -100,7 +113,7 @@ def make_local_component_tag(component_name, endpoint): :param endpoint: """ return zipkin_collector.BinaryAnnotation( - key=LOCAL_COMPONENT, value=component_name, + key=LOCAL_COMPONENT, value=str_to_binary(component_name), annotation_type=zipkin_collector.AnnotationType.STRING, host=endpoint) @@ -117,7 +130,7 @@ def timestamp_micros(ts): :param ts: :return: """ - return long(ts * 1000000) + return int(ts * 1000000) def make_zipkin_spans(spans): diff --git a/jaeger_client/thrift_gen/agent/Agent.py b/jaeger_client/thrift_gen/agent/Agent.py index af7aa2fc..e056557f 100644 --- a/jaeger_client/thrift_gen/agent/Agent.py +++ b/jaeger_client/thrift_gen/agent/Agent.py @@ -1,187 +1,178 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys import logging -from ttypes import * +from .ttypes import * from thrift.Thrift import TProcessor from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None - from tornado import gen from tornado import concurrent -from thrift.transport import TTransport + class Iface(object): - def emitZipkinBatch(self, spans): - """ - Parameters: - - spans - """ - pass + def emitZipkinBatch(self, spans): + """ + Parameters: + - spans + """ + pass class Client(Iface): - def __init__(self, transport, iprot_factory, oprot_factory=None): - self._transport = transport - self._iprot_factory = iprot_factory - self._oprot_factory = (oprot_factory if oprot_factory is not None - else iprot_factory) - self._seqid = 0 - self._reqs = {} - self._transport.io_loop.spawn_callback(self._start_receiving) - - @gen.engine - def _start_receiving(self): - while True: - try: - frame = yield self._transport.readFrame() - except TTransport.TTransportException as e: - for future in self._reqs.itervalues(): - future.set_exception(e) + def __init__(self, transport, iprot_factory, oprot_factory=None): + self._transport = transport + self._iprot_factory = iprot_factory + self._oprot_factory = (oprot_factory if oprot_factory is not None + else iprot_factory) + self._seqid = 0 self._reqs = {} - return - tr = TTransport.TMemoryBuffer(frame) - iprot = self._iprot_factory.getProtocol(tr) - (fname, mtype, rseqid) = iprot.readMessageBegin() - future = self._reqs.pop(rseqid, None) - if not future: - # future has already been discarded - continue - method = getattr(self, 'recv_' + fname) - try: - result = method(iprot, mtype, rseqid) - except Exception as e: - future.set_exception(e) - else: - future.set_result(result) - - def emitZipkinBatch(self, spans): - """ - Parameters: - - spans - """ - self._seqid += 1 - self.send_emitZipkinBatch(spans) - - def send_emitZipkinBatch(self, spans): - oprot = self._oprot_factory.getProtocol(self._transport) - oprot.writeMessageBegin('emitZipkinBatch', TMessageType.ONEWAY, self._seqid) - args = emitZipkinBatch_args() - args.spans = spans - args.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + self._transport.io_loop.spawn_callback(self._start_receiving) + + @gen.engine + def _start_receiving(self): + while True: + try: + frame = yield self._transport.readFrame() + except TTransport.TTransportException as e: + for future in self._reqs.values(): + future.set_exception(e) + self._reqs = {} + return + tr = TTransport.TMemoryBuffer(frame) + iprot = self._iprot_factory.getProtocol(tr) + (fname, mtype, rseqid) = iprot.readMessageBegin() + method = getattr(self, 'recv_' + fname) + future = self._reqs.pop(rseqid, None) + if not future: + # future has already been discarded + continue + try: + result = method(iprot, mtype, rseqid) + except Exception as e: + future.set_exception(e) + else: + future.set_result(result) + + def emitZipkinBatch(self, spans): + """ + Parameters: + - spans + """ + self._seqid += 1 + self.send_emitZipkinBatch(spans) + + def send_emitZipkinBatch(self, spans): + oprot = self._oprot_factory.getProtocol(self._transport) + oprot.writeMessageBegin('emitZipkinBatch', TMessageType.ONEWAY, self._seqid) + args = emitZipkinBatch_args() + args.spans = spans + args.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["emitZipkinBatch"] = Processor.process_emitZipkinBatch - - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) - iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - return self._processMap[name](self, seqid, iprot, oprot) - - @gen.coroutine - def process_emitZipkinBatch(self, seqid, iprot, oprot): - args = emitZipkinBatch_args() - args.read(iprot) - iprot.readMessageEnd() - yield gen.maybe_future(self._handler.emitZipkinBatch(args.spans)) + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["emitZipkinBatch"] = Processor.process_emitZipkinBatch + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + return self._processMap[name](self, seqid, iprot, oprot) + @gen.coroutine + def process_emitZipkinBatch(self, seqid, iprot, oprot): + args = emitZipkinBatch_args() + args.read(iprot) + iprot.readMessageEnd() + yield gen.maybe_future(self._handler.emitZipkinBatch(args.spans)) # HELPER FUNCTIONS AND STRUCTURES + class emitZipkinBatch_args(object): - """ - Attributes: - - spans - """ - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'spans', (TType.STRUCT,(zipkincore.ttypes.Span, zipkincore.ttypes.Span.thrift_spec)), None, ), # 1 - ) - - def __init__(self, spans=None,): - self.spans = spans - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.LIST: - self.spans = [] - (_etype3, _size0) = iprot.readListBegin() - for _i4 in xrange(_size0): - _elem5 = zipkincore.ttypes.Span() - _elem5.read(iprot) - self.spans.append(_elem5) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('emitZipkinBatch_args') - if self.spans is not None: - oprot.writeFieldBegin('spans', TType.LIST, 1) - oprot.writeListBegin(TType.STRUCT, len(self.spans)) - for iter6 in self.spans: - iter6.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.spans) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - spans + """ + + thrift_spec = ( + None, # 0 + (1, TType.LIST, 'spans', (TType.STRUCT, (zipkincore.ttypes.Span, zipkincore.ttypes.Span.thrift_spec), False), None, ), # 1 + ) + + def __init__(self, spans=None,): + self.spans = spans + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.LIST: + self.spans = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = zipkincore.ttypes.Span() + _elem5.read(iprot) + self.spans.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('emitZipkinBatch_args') + if self.spans is not None: + oprot.writeFieldBegin('spans', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.spans)) + for iter6 in self.spans: + iter6.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git a/jaeger_client/thrift_gen/agent/constants.py b/jaeger_client/thrift_gen/agent/constants.py index 12e384ed..cc5db551 100644 --- a/jaeger_client/thrift_gen/agent/constants.py +++ b/jaeger_client/thrift_gen/agent/constants.py @@ -1,11 +1,12 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException -from ttypes import * - +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys +from .ttypes import * diff --git a/jaeger_client/thrift_gen/agent/ttypes.py b/jaeger_client/thrift_gen/agent/ttypes.py index bec8bb48..28a32292 100644 --- a/jaeger_client/thrift_gen/agent/ttypes.py +++ b/jaeger_client/thrift_gen/agent/ttypes.py @@ -1,20 +1,14 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys import zipkincore.ttypes - from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None - - diff --git a/jaeger_client/thrift_gen/sampling/SamplingManager.py b/jaeger_client/thrift_gen/sampling/SamplingManager.py index 5144fc76..6904789f 100644 --- a/jaeger_client/thrift_gen/sampling/SamplingManager.py +++ b/jaeger_client/thrift_gen/sampling/SamplingManager.py @@ -1,264 +1,249 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys import logging -from ttypes import * +from .ttypes import * from thrift.Thrift import TProcessor from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None - from tornado import gen from tornado import concurrent -from thrift.transport import TTransport + class Iface(object): - def getSamplingStrategy(self, serviceName): - """ - Parameters: - - serviceName - """ - pass + def getSamplingStrategy(self, serviceName): + """ + Parameters: + - serviceName + """ + pass class Client(Iface): - def __init__(self, transport, iprot_factory, oprot_factory=None): - self._transport = transport - self._iprot_factory = iprot_factory - self._oprot_factory = (oprot_factory if oprot_factory is not None - else iprot_factory) - self._seqid = 0 - self._reqs = {} - self._transport.io_loop.spawn_callback(self._start_receiving) - - @gen.engine - def _start_receiving(self): - while True: - try: - frame = yield self._transport.readFrame() - except TTransport.TTransportException as e: - for future in self._reqs.itervalues(): - future.set_exception(e) + def __init__(self, transport, iprot_factory, oprot_factory=None): + self._transport = transport + self._iprot_factory = iprot_factory + self._oprot_factory = (oprot_factory if oprot_factory is not None + else iprot_factory) + self._seqid = 0 self._reqs = {} - return - tr = TTransport.TMemoryBuffer(frame) - iprot = self._iprot_factory.getProtocol(tr) - (fname, mtype, rseqid) = iprot.readMessageBegin() - future = self._reqs.pop(rseqid, None) - if not future: - # future has already been discarded - continue - method = getattr(self, 'recv_' + fname) - try: - result = method(iprot, mtype, rseqid) - except Exception as e: - future.set_exception(e) - else: - future.set_result(result) - - def getSamplingStrategy(self, serviceName): + self._transport.io_loop.spawn_callback(self._start_receiving) + + @gen.engine + def _start_receiving(self): + while True: + try: + frame = yield self._transport.readFrame() + except TTransport.TTransportException as e: + for future in self._reqs.values(): + future.set_exception(e) + self._reqs = {} + return + tr = TTransport.TMemoryBuffer(frame) + iprot = self._iprot_factory.getProtocol(tr) + (fname, mtype, rseqid) = iprot.readMessageBegin() + method = getattr(self, 'recv_' + fname) + future = self._reqs.pop(rseqid, None) + if not future: + # future has already been discarded + continue + try: + result = method(iprot, mtype, rseqid) + except Exception as e: + future.set_exception(e) + else: + future.set_result(result) + + def getSamplingStrategy(self, serviceName): + """ + Parameters: + - serviceName + """ + self._seqid += 1 + future = self._reqs[self._seqid] = concurrent.Future() + self.send_getSamplingStrategy(serviceName) + return future + + def send_getSamplingStrategy(self, serviceName): + oprot = self._oprot_factory.getProtocol(self._transport) + oprot.writeMessageBegin('getSamplingStrategy', TMessageType.CALL, self._seqid) + args = getSamplingStrategy_args() + args.serviceName = serviceName + args.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def recv_getSamplingStrategy(self, iprot, mtype, rseqid): + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = getSamplingStrategy_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "getSamplingStrategy failed: unknown result") + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["getSamplingStrategy"] = Processor.process_getSamplingStrategy + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + return self._processMap[name](self, seqid, iprot, oprot) + + @gen.coroutine + def process_getSamplingStrategy(self, seqid, iprot, oprot): + args = getSamplingStrategy_args() + args.read(iprot) + iprot.readMessageEnd() + result = getSamplingStrategy_result() + result.success = yield gen.maybe_future(self._handler.getSamplingStrategy(args.serviceName)) + oprot.writeMessageBegin("getSamplingStrategy", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + +# HELPER FUNCTIONS AND STRUCTURES + + +class getSamplingStrategy_args(object): """ - Parameters: + Attributes: - serviceName """ - self._seqid += 1 - future = self._reqs[self._seqid] = concurrent.Future() - self.send_getSamplingStrategy(serviceName) - return future - - def send_getSamplingStrategy(self, serviceName): - oprot = self._oprot_factory.getProtocol(self._transport) - oprot.writeMessageBegin('getSamplingStrategy', TMessageType.CALL, self._seqid) - args = getSamplingStrategy_args() - args.serviceName = serviceName - args.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def recv_getSamplingStrategy(self, iprot, mtype, rseqid): - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(iprot) - iprot.readMessageEnd() - raise x - result = getSamplingStrategy_result() - result.read(iprot) - iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "getSamplingStrategy failed: unknown result") + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'serviceName', 'UTF8', None, ), # 1 + ) + + def __init__(self, serviceName=None,): + self.serviceName = serviceName + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.serviceName = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('getSamplingStrategy_args') + if self.serviceName is not None: + oprot.writeFieldBegin('serviceName', TType.STRING, 1) + oprot.writeString(self.serviceName.encode('utf-8') if sys.version_info[0] == 2 else self.serviceName) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return -class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["getSamplingStrategy"] = Processor.process_getSamplingStrategy - - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) - iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - return self._processMap[name](self, seqid, iprot, oprot) - - @gen.coroutine - def process_getSamplingStrategy(self, seqid, iprot, oprot): - args = getSamplingStrategy_args() - args.read(iprot) - iprot.readMessageEnd() - result = getSamplingStrategy_result() - result.success = yield gen.maybe_future(self._handler.getSamplingStrategy(args.serviceName)) - oprot.writeMessageBegin("getSamplingStrategy", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ -# HELPER FUNCTIONS AND STRUCTURES + def __ne__(self, other): + return not (self == other) -class getSamplingStrategy_args(object): - """ - Attributes: - - serviceName - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'serviceName', None, None, ), # 1 - ) - - def __init__(self, serviceName=None,): - self.serviceName = serviceName - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.serviceName = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getSamplingStrategy_args') - if self.serviceName is not None: - oprot.writeFieldBegin('serviceName', TType.STRING, 1) - oprot.writeString(self.serviceName) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.serviceName) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) class getSamplingStrategy_result(object): - """ - Attributes: - - success - """ - - thrift_spec = ( - (0, TType.STRUCT, 'success', (SamplingStrategyResponse, SamplingStrategyResponse.thrift_spec), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRUCT: - self.success = SamplingStrategyResponse() - self.success.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('getSamplingStrategy_result') - if self.success is not None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.success) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - success + """ + + thrift_spec = ( + (0, TType.STRUCT, 'success', (SamplingStrategyResponse, SamplingStrategyResponse.thrift_spec), None, ), # 0 + ) + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = SamplingStrategyResponse() + self.success.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('getSamplingStrategy_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git a/jaeger_client/thrift_gen/sampling/constants.py b/jaeger_client/thrift_gen/sampling/constants.py index 12e384ed..cc5db551 100644 --- a/jaeger_client/thrift_gen/sampling/constants.py +++ b/jaeger_client/thrift_gen/sampling/constants.py @@ -1,11 +1,12 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException -from ttypes import * - +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys +from .ttypes import * diff --git a/jaeger_client/thrift_gen/sampling/ttypes.py b/jaeger_client/thrift_gen/sampling/ttypes.py index 4c81edd3..bcbc8d18 100644 --- a/jaeger_client/thrift_gen/sampling/ttypes.py +++ b/jaeger_client/thrift_gen/sampling/ttypes.py @@ -1,464 +1,429 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None class SamplingStrategyType(object): - PROBABILISTIC = 0 - RATE_LIMITING = 1 + PROBABILISTIC = 0 + RATE_LIMITING = 1 - _VALUES_TO_NAMES = { - 0: "PROBABILISTIC", - 1: "RATE_LIMITING", - } + _VALUES_TO_NAMES = { + 0: "PROBABILISTIC", + 1: "RATE_LIMITING", + } - _NAMES_TO_VALUES = { - "PROBABILISTIC": 0, - "RATE_LIMITING": 1, - } + _NAMES_TO_VALUES = { + "PROBABILISTIC": 0, + "RATE_LIMITING": 1, + } class ProbabilisticSamplingStrategy(object): - """ - Attributes: - - samplingRate - """ - - thrift_spec = ( - None, # 0 - (1, TType.DOUBLE, 'samplingRate', None, None, ), # 1 - ) - - def __init__(self, samplingRate=None,): - self.samplingRate = samplingRate - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.DOUBLE: - self.samplingRate = iprot.readDouble() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('ProbabilisticSamplingStrategy') - if self.samplingRate is not None: - oprot.writeFieldBegin('samplingRate', TType.DOUBLE, 1) - oprot.writeDouble(self.samplingRate) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - if self.samplingRate is None: - raise TProtocol.TProtocolException(message='Required field samplingRate is unset!') - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.samplingRate) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - samplingRate + """ + + thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'samplingRate', None, None, ), # 1 + ) + + def __init__(self, samplingRate=None,): + self.samplingRate = samplingRate + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.samplingRate = iprot.readDouble() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('ProbabilisticSamplingStrategy') + if self.samplingRate is not None: + oprot.writeFieldBegin('samplingRate', TType.DOUBLE, 1) + oprot.writeDouble(self.samplingRate) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.samplingRate is None: + raise TProtocolException(message='Required field samplingRate is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class RateLimitingSamplingStrategy(object): - """ - Attributes: - - maxTracesPerSecond - """ - - thrift_spec = ( - None, # 0 - (1, TType.I16, 'maxTracesPerSecond', None, None, ), # 1 - ) - - def __init__(self, maxTracesPerSecond=None,): - self.maxTracesPerSecond = maxTracesPerSecond - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I16: - self.maxTracesPerSecond = iprot.readI16() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('RateLimitingSamplingStrategy') - if self.maxTracesPerSecond is not None: - oprot.writeFieldBegin('maxTracesPerSecond', TType.I16, 1) - oprot.writeI16(self.maxTracesPerSecond) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - if self.maxTracesPerSecond is None: - raise TProtocol.TProtocolException(message='Required field maxTracesPerSecond is unset!') - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.maxTracesPerSecond) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - maxTracesPerSecond + """ + + thrift_spec = ( + None, # 0 + (1, TType.I16, 'maxTracesPerSecond', None, None, ), # 1 + ) + + def __init__(self, maxTracesPerSecond=None,): + self.maxTracesPerSecond = maxTracesPerSecond + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I16: + self.maxTracesPerSecond = iprot.readI16() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('RateLimitingSamplingStrategy') + if self.maxTracesPerSecond is not None: + oprot.writeFieldBegin('maxTracesPerSecond', TType.I16, 1) + oprot.writeI16(self.maxTracesPerSecond) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.maxTracesPerSecond is None: + raise TProtocolException(message='Required field maxTracesPerSecond is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class OperationSamplingStrategy(object): - """ - Attributes: - - operation - - probabilisticSampling - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'operation', None, None, ), # 1 - (2, TType.STRUCT, 'probabilisticSampling', (ProbabilisticSamplingStrategy, ProbabilisticSamplingStrategy.thrift_spec), None, ), # 2 - ) - - def __init__(self, operation=None, probabilisticSampling=None,): - self.operation = operation - self.probabilisticSampling = probabilisticSampling - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.operation = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.probabilisticSampling = ProbabilisticSamplingStrategy() - self.probabilisticSampling.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('OperationSamplingStrategy') - if self.operation is not None: - oprot.writeFieldBegin('operation', TType.STRING, 1) - oprot.writeString(self.operation) - oprot.writeFieldEnd() - if self.probabilisticSampling is not None: - oprot.writeFieldBegin('probabilisticSampling', TType.STRUCT, 2) - self.probabilisticSampling.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - if self.operation is None: - raise TProtocol.TProtocolException(message='Required field operation is unset!') - if self.probabilisticSampling is None: - raise TProtocol.TProtocolException(message='Required field probabilisticSampling is unset!') - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.operation) - value = (value * 31) ^ hash(self.probabilisticSampling) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - operation + - probabilisticSampling + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'operation', 'UTF8', None, ), # 1 + (2, TType.STRUCT, 'probabilisticSampling', (ProbabilisticSamplingStrategy, ProbabilisticSamplingStrategy.thrift_spec), None, ), # 2 + ) + + def __init__(self, operation=None, probabilisticSampling=None,): + self.operation = operation + self.probabilisticSampling = probabilisticSampling + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.operation = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.probabilisticSampling = ProbabilisticSamplingStrategy() + self.probabilisticSampling.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('OperationSamplingStrategy') + if self.operation is not None: + oprot.writeFieldBegin('operation', TType.STRING, 1) + oprot.writeString(self.operation.encode('utf-8') if sys.version_info[0] == 2 else self.operation) + oprot.writeFieldEnd() + if self.probabilisticSampling is not None: + oprot.writeFieldBegin('probabilisticSampling', TType.STRUCT, 2) + self.probabilisticSampling.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.operation is None: + raise TProtocolException(message='Required field operation is unset!') + if self.probabilisticSampling is None: + raise TProtocolException(message='Required field probabilisticSampling is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class PerOperationSamplingStrategies(object): - """ - Attributes: - - defaultSamplingProbability - - defaultLowerBoundTracesPerSecond - - perOperationStrategies - """ - - thrift_spec = ( - None, # 0 - (1, TType.DOUBLE, 'defaultSamplingProbability', None, None, ), # 1 - (2, TType.DOUBLE, 'defaultLowerBoundTracesPerSecond', None, None, ), # 2 - (3, TType.LIST, 'perOperationStrategies', (TType.STRUCT,(OperationSamplingStrategy, OperationSamplingStrategy.thrift_spec)), None, ), # 3 - ) - - def __init__(self, defaultSamplingProbability=None, defaultLowerBoundTracesPerSecond=None, perOperationStrategies=None,): - self.defaultSamplingProbability = defaultSamplingProbability - self.defaultLowerBoundTracesPerSecond = defaultLowerBoundTracesPerSecond - self.perOperationStrategies = perOperationStrategies - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.DOUBLE: - self.defaultSamplingProbability = iprot.readDouble() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.DOUBLE: - self.defaultLowerBoundTracesPerSecond = iprot.readDouble() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.LIST: - self.perOperationStrategies = [] - (_etype3, _size0) = iprot.readListBegin() - for _i4 in xrange(_size0): - _elem5 = OperationSamplingStrategy() - _elem5.read(iprot) - self.perOperationStrategies.append(_elem5) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('PerOperationSamplingStrategies') - if self.defaultSamplingProbability is not None: - oprot.writeFieldBegin('defaultSamplingProbability', TType.DOUBLE, 1) - oprot.writeDouble(self.defaultSamplingProbability) - oprot.writeFieldEnd() - if self.defaultLowerBoundTracesPerSecond is not None: - oprot.writeFieldBegin('defaultLowerBoundTracesPerSecond', TType.DOUBLE, 2) - oprot.writeDouble(self.defaultLowerBoundTracesPerSecond) - oprot.writeFieldEnd() - if self.perOperationStrategies is not None: - oprot.writeFieldBegin('perOperationStrategies', TType.LIST, 3) - oprot.writeListBegin(TType.STRUCT, len(self.perOperationStrategies)) - for iter6 in self.perOperationStrategies: - iter6.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - if self.defaultSamplingProbability is None: - raise TProtocol.TProtocolException(message='Required field defaultSamplingProbability is unset!') - if self.defaultLowerBoundTracesPerSecond is None: - raise TProtocol.TProtocolException(message='Required field defaultLowerBoundTracesPerSecond is unset!') - if self.perOperationStrategies is None: - raise TProtocol.TProtocolException(message='Required field perOperationStrategies is unset!') - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.defaultSamplingProbability) - value = (value * 31) ^ hash(self.defaultLowerBoundTracesPerSecond) - value = (value * 31) ^ hash(self.perOperationStrategies) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - defaultSamplingProbability + - defaultLowerBoundTracesPerSecond + - perOperationStrategies + """ + + thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'defaultSamplingProbability', None, None, ), # 1 + (2, TType.DOUBLE, 'defaultLowerBoundTracesPerSecond', None, None, ), # 2 + (3, TType.LIST, 'perOperationStrategies', (TType.STRUCT, (OperationSamplingStrategy, OperationSamplingStrategy.thrift_spec), False), None, ), # 3 + ) + + def __init__(self, defaultSamplingProbability=None, defaultLowerBoundTracesPerSecond=None, perOperationStrategies=None,): + self.defaultSamplingProbability = defaultSamplingProbability + self.defaultLowerBoundTracesPerSecond = defaultLowerBoundTracesPerSecond + self.perOperationStrategies = perOperationStrategies + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.defaultSamplingProbability = iprot.readDouble() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.DOUBLE: + self.defaultLowerBoundTracesPerSecond = iprot.readDouble() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.LIST: + self.perOperationStrategies = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = OperationSamplingStrategy() + _elem5.read(iprot) + self.perOperationStrategies.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('PerOperationSamplingStrategies') + if self.defaultSamplingProbability is not None: + oprot.writeFieldBegin('defaultSamplingProbability', TType.DOUBLE, 1) + oprot.writeDouble(self.defaultSamplingProbability) + oprot.writeFieldEnd() + if self.defaultLowerBoundTracesPerSecond is not None: + oprot.writeFieldBegin('defaultLowerBoundTracesPerSecond', TType.DOUBLE, 2) + oprot.writeDouble(self.defaultLowerBoundTracesPerSecond) + oprot.writeFieldEnd() + if self.perOperationStrategies is not None: + oprot.writeFieldBegin('perOperationStrategies', TType.LIST, 3) + oprot.writeListBegin(TType.STRUCT, len(self.perOperationStrategies)) + for iter6 in self.perOperationStrategies: + iter6.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.defaultSamplingProbability is None: + raise TProtocolException(message='Required field defaultSamplingProbability is unset!') + if self.defaultLowerBoundTracesPerSecond is None: + raise TProtocolException(message='Required field defaultLowerBoundTracesPerSecond is unset!') + if self.perOperationStrategies is None: + raise TProtocolException(message='Required field perOperationStrategies is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class SamplingStrategyResponse(object): - """ - Attributes: - - strategyType - - probabilisticSampling - - rateLimitingSampling - - operationSampling - """ - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'strategyType', None, None, ), # 1 - (2, TType.STRUCT, 'probabilisticSampling', (ProbabilisticSamplingStrategy, ProbabilisticSamplingStrategy.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'rateLimitingSampling', (RateLimitingSamplingStrategy, RateLimitingSamplingStrategy.thrift_spec), None, ), # 3 - (4, TType.STRUCT, 'operationSampling', (PerOperationSamplingStrategies, PerOperationSamplingStrategies.thrift_spec), None, ), # 4 - ) - - def __init__(self, strategyType=None, probabilisticSampling=None, rateLimitingSampling=None, operationSampling=None,): - self.strategyType = strategyType - self.probabilisticSampling = probabilisticSampling - self.rateLimitingSampling = rateLimitingSampling - self.operationSampling = operationSampling - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I32: - self.strategyType = iprot.readI32() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.probabilisticSampling = ProbabilisticSamplingStrategy() - self.probabilisticSampling.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.rateLimitingSampling = RateLimitingSamplingStrategy() - self.rateLimitingSampling.read(iprot) - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.STRUCT: - self.operationSampling = PerOperationSamplingStrategies() - self.operationSampling.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('SamplingStrategyResponse') - if self.strategyType is not None: - oprot.writeFieldBegin('strategyType', TType.I32, 1) - oprot.writeI32(self.strategyType) - oprot.writeFieldEnd() - if self.probabilisticSampling is not None: - oprot.writeFieldBegin('probabilisticSampling', TType.STRUCT, 2) - self.probabilisticSampling.write(oprot) - oprot.writeFieldEnd() - if self.rateLimitingSampling is not None: - oprot.writeFieldBegin('rateLimitingSampling', TType.STRUCT, 3) - self.rateLimitingSampling.write(oprot) - oprot.writeFieldEnd() - if self.operationSampling is not None: - oprot.writeFieldBegin('operationSampling', TType.STRUCT, 4) - self.operationSampling.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - if self.strategyType is None: - raise TProtocol.TProtocolException(message='Required field strategyType is unset!') - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.strategyType) - value = (value * 31) ^ hash(self.probabilisticSampling) - value = (value * 31) ^ hash(self.rateLimitingSampling) - value = (value * 31) ^ hash(self.operationSampling) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - strategyType + - probabilisticSampling + - rateLimitingSampling + - operationSampling + """ + + thrift_spec = ( + None, # 0 + (1, TType.I32, 'strategyType', None, None, ), # 1 + (2, TType.STRUCT, 'probabilisticSampling', (ProbabilisticSamplingStrategy, ProbabilisticSamplingStrategy.thrift_spec), None, ), # 2 + (3, TType.STRUCT, 'rateLimitingSampling', (RateLimitingSamplingStrategy, RateLimitingSamplingStrategy.thrift_spec), None, ), # 3 + (4, TType.STRUCT, 'operationSampling', (PerOperationSamplingStrategies, PerOperationSamplingStrategies.thrift_spec), None, ), # 4 + ) + + def __init__(self, strategyType=None, probabilisticSampling=None, rateLimitingSampling=None, operationSampling=None,): + self.strategyType = strategyType + self.probabilisticSampling = probabilisticSampling + self.rateLimitingSampling = rateLimitingSampling + self.operationSampling = operationSampling + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.strategyType = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.probabilisticSampling = ProbabilisticSamplingStrategy() + self.probabilisticSampling.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.rateLimitingSampling = RateLimitingSamplingStrategy() + self.rateLimitingSampling.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.operationSampling = PerOperationSamplingStrategies() + self.operationSampling.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('SamplingStrategyResponse') + if self.strategyType is not None: + oprot.writeFieldBegin('strategyType', TType.I32, 1) + oprot.writeI32(self.strategyType) + oprot.writeFieldEnd() + if self.probabilisticSampling is not None: + oprot.writeFieldBegin('probabilisticSampling', TType.STRUCT, 2) + self.probabilisticSampling.write(oprot) + oprot.writeFieldEnd() + if self.rateLimitingSampling is not None: + oprot.writeFieldBegin('rateLimitingSampling', TType.STRUCT, 3) + self.rateLimitingSampling.write(oprot) + oprot.writeFieldEnd() + if self.operationSampling is not None: + oprot.writeFieldBegin('operationSampling', TType.STRUCT, 4) + self.operationSampling.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.strategyType is None: + raise TProtocolException(message='Required field strategyType is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git a/jaeger_client/thrift_gen/zipkincore/ZipkinCollector.py b/jaeger_client/thrift_gen/zipkincore/ZipkinCollector.py index 72d84f5c..2d27a030 100644 --- a/jaeger_client/thrift_gen/zipkincore/ZipkinCollector.py +++ b/jaeger_client/thrift_gen/zipkincore/ZipkinCollector.py @@ -1,281 +1,266 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys import logging -from ttypes import * +from .ttypes import * from thrift.Thrift import TProcessor from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None - from tornado import gen from tornado import concurrent -from thrift.transport import TTransport + class Iface(object): - def submitZipkinBatch(self, spans): - """ - Parameters: - - spans - """ - pass + def submitZipkinBatch(self, spans): + """ + Parameters: + - spans + """ + pass class Client(Iface): - def __init__(self, transport, iprot_factory, oprot_factory=None): - self._transport = transport - self._iprot_factory = iprot_factory - self._oprot_factory = (oprot_factory if oprot_factory is not None - else iprot_factory) - self._seqid = 0 - self._reqs = {} - self._transport.io_loop.spawn_callback(self._start_receiving) - - @gen.engine - def _start_receiving(self): - while True: - try: - frame = yield self._transport.readFrame() - except TTransport.TTransportException as e: - for future in self._reqs.itervalues(): - future.set_exception(e) + def __init__(self, transport, iprot_factory, oprot_factory=None): + self._transport = transport + self._iprot_factory = iprot_factory + self._oprot_factory = (oprot_factory if oprot_factory is not None + else iprot_factory) + self._seqid = 0 self._reqs = {} - return - tr = TTransport.TMemoryBuffer(frame) - iprot = self._iprot_factory.getProtocol(tr) - (fname, mtype, rseqid) = iprot.readMessageBegin() - future = self._reqs.pop(rseqid, None) - if not future: - # future has already been discarded - continue - method = getattr(self, 'recv_' + fname) - try: - result = method(iprot, mtype, rseqid) - except Exception as e: - future.set_exception(e) - else: - future.set_result(result) - - def submitZipkinBatch(self, spans): + self._transport.io_loop.spawn_callback(self._start_receiving) + + @gen.engine + def _start_receiving(self): + while True: + try: + frame = yield self._transport.readFrame() + except TTransport.TTransportException as e: + for future in self._reqs.values(): + future.set_exception(e) + self._reqs = {} + return + tr = TTransport.TMemoryBuffer(frame) + iprot = self._iprot_factory.getProtocol(tr) + (fname, mtype, rseqid) = iprot.readMessageBegin() + method = getattr(self, 'recv_' + fname) + future = self._reqs.pop(rseqid, None) + if not future: + # future has already been discarded + continue + try: + result = method(iprot, mtype, rseqid) + except Exception as e: + future.set_exception(e) + else: + future.set_result(result) + + def submitZipkinBatch(self, spans): + """ + Parameters: + - spans + """ + self._seqid += 1 + future = self._reqs[self._seqid] = concurrent.Future() + self.send_submitZipkinBatch(spans) + return future + + def send_submitZipkinBatch(self, spans): + oprot = self._oprot_factory.getProtocol(self._transport) + oprot.writeMessageBegin('submitZipkinBatch', TMessageType.CALL, self._seqid) + args = submitZipkinBatch_args() + args.spans = spans + args.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def recv_submitZipkinBatch(self, iprot, mtype, rseqid): + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = submitZipkinBatch_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + raise TApplicationException(TApplicationException.MISSING_RESULT, "submitZipkinBatch failed: unknown result") + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["submitZipkinBatch"] = Processor.process_submitZipkinBatch + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + return self._processMap[name](self, seqid, iprot, oprot) + + @gen.coroutine + def process_submitZipkinBatch(self, seqid, iprot, oprot): + args = submitZipkinBatch_args() + args.read(iprot) + iprot.readMessageEnd() + result = submitZipkinBatch_result() + result.success = yield gen.maybe_future(self._handler.submitZipkinBatch(args.spans)) + oprot.writeMessageBegin("submitZipkinBatch", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + +# HELPER FUNCTIONS AND STRUCTURES + + +class submitZipkinBatch_args(object): """ - Parameters: + Attributes: - spans """ - self._seqid += 1 - future = self._reqs[self._seqid] = concurrent.Future() - self.send_submitZipkinBatch(spans) - return future - - def send_submitZipkinBatch(self, spans): - oprot = self._oprot_factory.getProtocol(self._transport) - oprot.writeMessageBegin('submitZipkinBatch', TMessageType.CALL, self._seqid) - args = submitZipkinBatch_args() - args.spans = spans - args.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def recv_submitZipkinBatch(self, iprot, mtype, rseqid): - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(iprot) - iprot.readMessageEnd() - raise x - result = submitZipkinBatch_result() - result.read(iprot) - iprot.readMessageEnd() - if result.success is not None: - return result.success - raise TApplicationException(TApplicationException.MISSING_RESULT, "submitZipkinBatch failed: unknown result") + thrift_spec = ( + None, # 0 + (1, TType.LIST, 'spans', (TType.STRUCT, (Span, Span.thrift_spec), False), None, ), # 1 + ) + + def __init__(self, spans=None,): + self.spans = spans + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.LIST: + self.spans = [] + (_etype17, _size14) = iprot.readListBegin() + for _i18 in range(_size14): + _elem19 = Span() + _elem19.read(iprot) + self.spans.append(_elem19) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('submitZipkinBatch_args') + if self.spans is not None: + oprot.writeFieldBegin('spans', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.spans)) + for iter20 in self.spans: + iter20.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return -class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["submitZipkinBatch"] = Processor.process_submitZipkinBatch - - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) - iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - return self._processMap[name](self, seqid, iprot, oprot) - - @gen.coroutine - def process_submitZipkinBatch(self, seqid, iprot, oprot): - args = submitZipkinBatch_args() - args.read(iprot) - iprot.readMessageEnd() - result = submitZipkinBatch_result() - result.success = yield gen.maybe_future(self._handler.submitZipkinBatch(args.spans)) - oprot.writeMessageBegin("submitZipkinBatch", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ -# HELPER FUNCTIONS AND STRUCTURES + def __ne__(self, other): + return not (self == other) -class submitZipkinBatch_args(object): - """ - Attributes: - - spans - """ - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'spans', (TType.STRUCT,(Span, Span.thrift_spec)), None, ), # 1 - ) - - def __init__(self, spans=None,): - self.spans = spans - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.LIST: - self.spans = [] - (_etype17, _size14) = iprot.readListBegin() - for _i18 in xrange(_size14): - _elem19 = Span() - _elem19.read(iprot) - self.spans.append(_elem19) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('submitZipkinBatch_args') - if self.spans is not None: - oprot.writeFieldBegin('spans', TType.LIST, 1) - oprot.writeListBegin(TType.STRUCT, len(self.spans)) - for iter20 in self.spans: - iter20.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.spans) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) class submitZipkinBatch_result(object): - """ - Attributes: - - success - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(Response, Response.thrift_spec)), None, ), # 0 - ) - - def __init__(self, success=None,): - self.success = success - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype24, _size21) = iprot.readListBegin() - for _i25 in xrange(_size21): - _elem26 = Response() - _elem26.read(iprot) - self.success.append(_elem26) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('submitZipkinBatch_result') - if self.success is not None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter27 in self.success: - iter27.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.success) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - success + """ + + thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT, (Response, Response.thrift_spec), False), None, ), # 0 + ) + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype24, _size21) = iprot.readListBegin() + for _i25 in range(_size21): + _elem26 = Response() + _elem26.read(iprot) + self.success.append(_elem26) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('submitZipkinBatch_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRUCT, len(self.success)) + for iter27 in self.success: + iter27.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git a/jaeger_client/thrift_gen/zipkincore/constants.py b/jaeger_client/thrift_gen/zipkincore/constants.py index 7b72c2b0..a85e4f7c 100644 --- a/jaeger_client/thrift_gen/zipkincore/constants.py +++ b/jaeger_client/thrift_gen/zipkincore/constants.py @@ -1,14 +1,15 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException -from ttypes import * - +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys +from .ttypes import * CLIENT_SEND = "cs" CLIENT_RECV = "cr" SERVER_SEND = "ss" diff --git a/jaeger_client/thrift_gen/zipkincore/ttypes.py b/jaeger_client/thrift_gen/zipkincore/ttypes.py index 6898ec29..f9d579d6 100644 --- a/jaeger_client/thrift_gen/zipkincore/ttypes.py +++ b/jaeger_client/thrift_gen/zipkincore/ttypes.py @@ -1,666 +1,622 @@ # -# Autogenerated by Thrift Compiler (0.9.3) +# Autogenerated by Thrift Compiler (0.10.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # # options string: py:new_style,tornado # -from thrift.Thrift import TType, TMessageType, TException, TApplicationException +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +import sys from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol, TProtocol -try: - from thrift.protocol import fastbinary -except: - fastbinary = None class AnnotationType(object): - BOOL = 0 - BYTES = 1 - I16 = 2 - I32 = 3 - I64 = 4 - DOUBLE = 5 - STRING = 6 - - _VALUES_TO_NAMES = { - 0: "BOOL", - 1: "BYTES", - 2: "I16", - 3: "I32", - 4: "I64", - 5: "DOUBLE", - 6: "STRING", - } - - _NAMES_TO_VALUES = { - "BOOL": 0, - "BYTES": 1, - "I16": 2, - "I32": 3, - "I64": 4, - "DOUBLE": 5, - "STRING": 6, - } + BOOL = 0 + BYTES = 1 + I16 = 2 + I32 = 3 + I64 = 4 + DOUBLE = 5 + STRING = 6 + + _VALUES_TO_NAMES = { + 0: "BOOL", + 1: "BYTES", + 2: "I16", + 3: "I32", + 4: "I64", + 5: "DOUBLE", + 6: "STRING", + } + + _NAMES_TO_VALUES = { + "BOOL": 0, + "BYTES": 1, + "I16": 2, + "I32": 3, + "I64": 4, + "DOUBLE": 5, + "STRING": 6, + } class Endpoint(object): - """ - Indicates the network context of a service recording an annotation with two - exceptions. - - When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, - the endpoint indicates the source or destination of an RPC. This exception - allows zipkin to display network context of uninstrumented services, or - clients such as web browsers. - - Attributes: - - ipv4: IPv4 host address packed into 4 bytes. - - Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 - - port: IPv4 port - - Note: this is to be treated as an unsigned integer, so watch for negatives. - - Conventionally, when the port isn't known, port = 0. - - service_name: Service name in lowercase, such as "memcache" or "zipkin-web" - - Conventionally, when the service name isn't known, service_name = "unknown". - """ - - thrift_spec = ( - None, # 0 - (1, TType.I32, 'ipv4', None, None, ), # 1 - (2, TType.I16, 'port', None, None, ), # 2 - (3, TType.STRING, 'service_name', None, None, ), # 3 - ) - - def __init__(self, ipv4=None, port=None, service_name=None,): - self.ipv4 = ipv4 - self.port = port - self.service_name = service_name - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I32: - self.ipv4 = iprot.readI32() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I16: - self.port = iprot.readI16() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.service_name = iprot.readString() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('Endpoint') - if self.ipv4 is not None: - oprot.writeFieldBegin('ipv4', TType.I32, 1) - oprot.writeI32(self.ipv4) - oprot.writeFieldEnd() - if self.port is not None: - oprot.writeFieldBegin('port', TType.I16, 2) - oprot.writeI16(self.port) - oprot.writeFieldEnd() - if self.service_name is not None: - oprot.writeFieldBegin('service_name', TType.STRING, 3) - oprot.writeString(self.service_name) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.ipv4) - value = (value * 31) ^ hash(self.port) - value = (value * 31) ^ hash(self.service_name) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Indicates the network context of a service recording an annotation with two + exceptions. + + When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, + the endpoint indicates the source or destination of an RPC. This exception + allows zipkin to display network context of uninstrumented services, or + clients such as web browsers. + + Attributes: + - ipv4: IPv4 host address packed into 4 bytes. + + Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 + - port: IPv4 port + + Note: this is to be treated as an unsigned integer, so watch for negatives. + + Conventionally, when the port isn't known, port = 0. + - service_name: Service name in lowercase, such as "memcache" or "zipkin-web" + + Conventionally, when the service name isn't known, service_name = "unknown". + """ + + thrift_spec = ( + None, # 0 + (1, TType.I32, 'ipv4', None, None, ), # 1 + (2, TType.I16, 'port', None, None, ), # 2 + (3, TType.STRING, 'service_name', 'UTF8', None, ), # 3 + ) + + def __init__(self, ipv4=None, port=None, service_name=None,): + self.ipv4 = ipv4 + self.port = port + self.service_name = service_name + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.ipv4 = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I16: + self.port = iprot.readI16() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.service_name = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('Endpoint') + if self.ipv4 is not None: + oprot.writeFieldBegin('ipv4', TType.I32, 1) + oprot.writeI32(self.ipv4) + oprot.writeFieldEnd() + if self.port is not None: + oprot.writeFieldBegin('port', TType.I16, 2) + oprot.writeI16(self.port) + oprot.writeFieldEnd() + if self.service_name is not None: + oprot.writeFieldBegin('service_name', TType.STRING, 3) + oprot.writeString(self.service_name.encode('utf-8') if sys.version_info[0] == 2 else self.service_name) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class Annotation(object): - """ - An annotation is similar to a log statement. It includes a host field which - allows these events to be attributed properly, and also aggregatable. - - Attributes: - - timestamp: Microseconds from epoch. - - This value should use the most precise value possible. For example, - gettimeofday or syncing nanoTime against a tick of currentTimeMillis. - - value - - host: Always the host that recorded the event. By specifying the host you allow - rollup of all events (such as client requests to a service) by IP address. - """ - - thrift_spec = ( - None, # 0 - (1, TType.I64, 'timestamp', None, None, ), # 1 - (2, TType.STRING, 'value', None, None, ), # 2 - (3, TType.STRUCT, 'host', (Endpoint, Endpoint.thrift_spec), None, ), # 3 - ) - - def __init__(self, timestamp=None, value=None, host=None,): - self.timestamp = timestamp - self.value = value - self.host = host - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I64: - self.timestamp = iprot.readI64() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.value = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.host = Endpoint() - self.host.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('Annotation') - if self.timestamp is not None: - oprot.writeFieldBegin('timestamp', TType.I64, 1) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - if self.value is not None: - oprot.writeFieldBegin('value', TType.STRING, 2) - oprot.writeString(self.value) - oprot.writeFieldEnd() - if self.host is not None: - oprot.writeFieldBegin('host', TType.STRUCT, 3) - self.host.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.timestamp) - value = (value * 31) ^ hash(self.value) - value = (value * 31) ^ hash(self.host) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + An annotation is similar to a log statement. It includes a host field which + allows these events to be attributed properly, and also aggregatable. + + Attributes: + - timestamp: Microseconds from epoch. + + This value should use the most precise value possible. For example, + gettimeofday or syncing nanoTime against a tick of currentTimeMillis. + - value + - host: Always the host that recorded the event. By specifying the host you allow + rollup of all events (such as client requests to a service) by IP address. + """ + + thrift_spec = ( + None, # 0 + (1, TType.I64, 'timestamp', None, None, ), # 1 + (2, TType.STRING, 'value', 'UTF8', None, ), # 2 + (3, TType.STRUCT, 'host', (Endpoint, Endpoint.thrift_spec), None, ), # 3 + ) + + def __init__(self, timestamp=None, value=None, host=None,): + self.timestamp = timestamp + self.value = value + self.host = host + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I64: + self.timestamp = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.value = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.host = Endpoint() + self.host.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('Annotation') + if self.timestamp is not None: + oprot.writeFieldBegin('timestamp', TType.I64, 1) + oprot.writeI64(self.timestamp) + oprot.writeFieldEnd() + if self.value is not None: + oprot.writeFieldBegin('value', TType.STRING, 2) + oprot.writeString(self.value.encode('utf-8') if sys.version_info[0] == 2 else self.value) + oprot.writeFieldEnd() + if self.host is not None: + oprot.writeFieldBegin('host', TType.STRUCT, 3) + self.host.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class BinaryAnnotation(object): - """ - Binary annotations are tags applied to a Span to give it context. For - example, a binary annotation of "http.uri" could the path to a resource in a - RPC call. - - Binary annotations of type STRING are always queryable, though more a - historical implementation detail than a structural concern. - - Binary annotations can repeat, and vary on the host. Similar to Annotation, - the host indicates who logged the event. This allows you to tell the - difference between the client and server side of the same key. For example, - the key "http.uri" might be different on the client and server side due to - rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, - you can see the different points of view, which often help in debugging. - - Attributes: - - key - - value - - annotation_type - - host: The host that recorded tag, which allows you to differentiate between - multiple tags with the same key. There are two exceptions to this. - - When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or - destination of an RPC. This exception allows zipkin to display network - context of uninstrumented services, or clients such as web browsers. - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'key', None, None, ), # 1 - (2, TType.STRING, 'value', None, None, ), # 2 - (3, TType.I32, 'annotation_type', None, None, ), # 3 - (4, TType.STRUCT, 'host', (Endpoint, Endpoint.thrift_spec), None, ), # 4 - ) - - def __init__(self, key=None, value=None, annotation_type=None, host=None,): - self.key = key - self.value = value - self.annotation_type = annotation_type - self.host = host - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.key = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRING: - self.value = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I32: - self.annotation_type = iprot.readI32() - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.STRUCT: - self.host = Endpoint() - self.host.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('BinaryAnnotation') - if self.key is not None: - oprot.writeFieldBegin('key', TType.STRING, 1) - oprot.writeString(self.key) - oprot.writeFieldEnd() - if self.value is not None: - oprot.writeFieldBegin('value', TType.STRING, 2) - oprot.writeString(self.value) - oprot.writeFieldEnd() - if self.annotation_type is not None: - oprot.writeFieldBegin('annotation_type', TType.I32, 3) - oprot.writeI32(self.annotation_type) - oprot.writeFieldEnd() - if self.host is not None: - oprot.writeFieldBegin('host', TType.STRUCT, 4) - self.host.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.key) - value = (value * 31) ^ hash(self.value) - value = (value * 31) ^ hash(self.annotation_type) - value = (value * 31) ^ hash(self.host) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Binary annotations are tags applied to a Span to give it context. For + example, a binary annotation of "http.uri" could the path to a resource in a + RPC call. + + Binary annotations of type STRING are always queryable, though more a + historical implementation detail than a structural concern. + + Binary annotations can repeat, and vary on the host. Similar to Annotation, + the host indicates who logged the event. This allows you to tell the + difference between the client and server side of the same key. For example, + the key "http.uri" might be different on the client and server side due to + rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, + you can see the different points of view, which often help in debugging. + + Attributes: + - key + - value + - annotation_type + - host: The host that recorded tag, which allows you to differentiate between + multiple tags with the same key. There are two exceptions to this. + + When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or + destination of an RPC. This exception allows zipkin to display network + context of uninstrumented services, or clients such as web browsers. + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', 'UTF8', None, ), # 1 + (2, TType.STRING, 'value', 'BINARY', None, ), # 2 + (3, TType.I32, 'annotation_type', None, None, ), # 3 + (4, TType.STRUCT, 'host', (Endpoint, Endpoint.thrift_spec), None, ), # 4 + ) + + def __init__(self, key=None, value=None, annotation_type=None, host=None,): + self.key = key + self.value = value + self.annotation_type = annotation_type + self.host = host + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.key = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.value = iprot.readBinary() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I32: + self.annotation_type = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.host = Endpoint() + self.host.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('BinaryAnnotation') + if self.key is not None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeString(self.key.encode('utf-8') if sys.version_info[0] == 2 else self.key) + oprot.writeFieldEnd() + if self.value is not None: + oprot.writeFieldBegin('value', TType.STRING, 2) + oprot.writeBinary(self.value) + oprot.writeFieldEnd() + if self.annotation_type is not None: + oprot.writeFieldBegin('annotation_type', TType.I32, 3) + oprot.writeI32(self.annotation_type) + oprot.writeFieldEnd() + if self.host is not None: + oprot.writeFieldBegin('host', TType.STRUCT, 4) + self.host.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class Span(object): - """ - A trace is a series of spans (often RPC calls) which form a latency tree. - - The root span is where trace_id = id and parent_id = Nil. The root span is - usually the longest interval in the trace, starting with a SERVER_RECV - annotation and ending with a SERVER_SEND. - - Attributes: - - trace_id - - name: Span name in lowercase, rpc method for example - - Conventionally, when the span name isn't known, name = "unknown". - - id - - parent_id - - annotations - - binary_annotations - - debug - - timestamp: Microseconds from epoch of the creation of this span. - - This value should be set directly by instrumentation, using the most - precise value possible. For example, gettimeofday or syncing nanoTime - against a tick of currentTimeMillis. - - For compatibilty with instrumentation that precede this field, collectors - or span stores can derive this via Annotation.timestamp. - For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. - - This field is optional for compatibility with old data: first-party span - stores are expected to support this at time of introduction. - - duration: Measurement of duration in microseconds, used to support queries. - - This value should be set directly, where possible. Doing so encourages - precise measurement decoupled from problems of clocks, such as skew or NTP - updates causing time to move backwards. - - For compatibilty with instrumentation that precede this field, collectors - or span stores can derive this by subtracting Annotation.timestamp. - For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. - - If this field is persisted as unset, zipkin will continue to work, except - duration query support will be implementation-specific. Similarly, setting - this field non-atomically is implementation-specific. - - This field is i64 vs i32 to support spans longer than 35 minutes. - """ - - thrift_spec = ( - None, # 0 - (1, TType.I64, 'trace_id', None, None, ), # 1 - None, # 2 - (3, TType.STRING, 'name', None, None, ), # 3 - (4, TType.I64, 'id', None, None, ), # 4 - (5, TType.I64, 'parent_id', None, None, ), # 5 - (6, TType.LIST, 'annotations', (TType.STRUCT,(Annotation, Annotation.thrift_spec)), None, ), # 6 - None, # 7 - (8, TType.LIST, 'binary_annotations', (TType.STRUCT,(BinaryAnnotation, BinaryAnnotation.thrift_spec)), None, ), # 8 - (9, TType.BOOL, 'debug', None, False, ), # 9 - (10, TType.I64, 'timestamp', None, None, ), # 10 - (11, TType.I64, 'duration', None, None, ), # 11 - ) - - def __init__(self, trace_id=None, name=None, id=None, parent_id=None, annotations=None, binary_annotations=None, debug=thrift_spec[9][4], timestamp=None, duration=None,): - self.trace_id = trace_id - self.name = name - self.id = id - self.parent_id = parent_id - self.annotations = annotations - self.binary_annotations = binary_annotations - self.debug = debug - self.timestamp = timestamp - self.duration = duration - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.I64: - self.trace_id = iprot.readI64() - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRING: - self.name = iprot.readString() - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I64: - self.id = iprot.readI64() - else: - iprot.skip(ftype) - elif fid == 5: - if ftype == TType.I64: - self.parent_id = iprot.readI64() - else: - iprot.skip(ftype) - elif fid == 6: - if ftype == TType.LIST: - self.annotations = [] - (_etype3, _size0) = iprot.readListBegin() - for _i4 in xrange(_size0): - _elem5 = Annotation() - _elem5.read(iprot) - self.annotations.append(_elem5) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 8: - if ftype == TType.LIST: - self.binary_annotations = [] - (_etype9, _size6) = iprot.readListBegin() - for _i10 in xrange(_size6): - _elem11 = BinaryAnnotation() - _elem11.read(iprot) - self.binary_annotations.append(_elem11) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 9: - if ftype == TType.BOOL: - self.debug = iprot.readBool() - else: - iprot.skip(ftype) - elif fid == 10: - if ftype == TType.I64: - self.timestamp = iprot.readI64() - else: - iprot.skip(ftype) - elif fid == 11: - if ftype == TType.I64: - self.duration = iprot.readI64() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('Span') - if self.trace_id is not None: - oprot.writeFieldBegin('trace_id', TType.I64, 1) - oprot.writeI64(self.trace_id) - oprot.writeFieldEnd() - if self.name is not None: - oprot.writeFieldBegin('name', TType.STRING, 3) - oprot.writeString(self.name) - oprot.writeFieldEnd() - if self.id is not None: - oprot.writeFieldBegin('id', TType.I64, 4) - oprot.writeI64(self.id) - oprot.writeFieldEnd() - if self.parent_id is not None: - oprot.writeFieldBegin('parent_id', TType.I64, 5) - oprot.writeI64(self.parent_id) - oprot.writeFieldEnd() - if self.annotations is not None: - oprot.writeFieldBegin('annotations', TType.LIST, 6) - oprot.writeListBegin(TType.STRUCT, len(self.annotations)) - for iter12 in self.annotations: - iter12.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.binary_annotations is not None: - oprot.writeFieldBegin('binary_annotations', TType.LIST, 8) - oprot.writeListBegin(TType.STRUCT, len(self.binary_annotations)) - for iter13 in self.binary_annotations: - iter13.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.debug is not None: - oprot.writeFieldBegin('debug', TType.BOOL, 9) - oprot.writeBool(self.debug) - oprot.writeFieldEnd() - if self.timestamp is not None: - oprot.writeFieldBegin('timestamp', TType.I64, 10) - oprot.writeI64(self.timestamp) - oprot.writeFieldEnd() - if self.duration is not None: - oprot.writeFieldBegin('duration', TType.I64, 11) - oprot.writeI64(self.duration) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.trace_id) - value = (value * 31) ^ hash(self.name) - value = (value * 31) ^ hash(self.id) - value = (value * 31) ^ hash(self.parent_id) - value = (value * 31) ^ hash(self.annotations) - value = (value * 31) ^ hash(self.binary_annotations) - value = (value * 31) ^ hash(self.debug) - value = (value * 31) ^ hash(self.timestamp) - value = (value * 31) ^ hash(self.duration) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + A trace is a series of spans (often RPC calls) which form a latency tree. + + The root span is where trace_id = id and parent_id = Nil. The root span is + usually the longest interval in the trace, starting with a SERVER_RECV + annotation and ending with a SERVER_SEND. + + Attributes: + - trace_id + - name: Span name in lowercase, rpc method for example + + Conventionally, when the span name isn't known, name = "unknown". + - id + - parent_id + - annotations + - binary_annotations + - debug + - timestamp: Microseconds from epoch of the creation of this span. + + This value should be set directly by instrumentation, using the most + precise value possible. For example, gettimeofday or syncing nanoTime + against a tick of currentTimeMillis. + + For compatibilty with instrumentation that precede this field, collectors + or span stores can derive this via Annotation.timestamp. + For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. + + This field is optional for compatibility with old data: first-party span + stores are expected to support this at time of introduction. + - duration: Measurement of duration in microseconds, used to support queries. + + This value should be set directly, where possible. Doing so encourages + precise measurement decoupled from problems of clocks, such as skew or NTP + updates causing time to move backwards. + + For compatibilty with instrumentation that precede this field, collectors + or span stores can derive this by subtracting Annotation.timestamp. + For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. + + If this field is persisted as unset, zipkin will continue to work, except + duration query support will be implementation-specific. Similarly, setting + this field non-atomically is implementation-specific. + + This field is i64 vs i32 to support spans longer than 35 minutes. + """ + + thrift_spec = ( + None, # 0 + (1, TType.I64, 'trace_id', None, None, ), # 1 + None, # 2 + (3, TType.STRING, 'name', 'UTF8', None, ), # 3 + (4, TType.I64, 'id', None, None, ), # 4 + (5, TType.I64, 'parent_id', None, None, ), # 5 + (6, TType.LIST, 'annotations', (TType.STRUCT, (Annotation, Annotation.thrift_spec), False), None, ), # 6 + None, # 7 + (8, TType.LIST, 'binary_annotations', (TType.STRUCT, (BinaryAnnotation, BinaryAnnotation.thrift_spec), False), None, ), # 8 + (9, TType.BOOL, 'debug', None, False, ), # 9 + (10, TType.I64, 'timestamp', None, None, ), # 10 + (11, TType.I64, 'duration', None, None, ), # 11 + ) + + def __init__(self, trace_id=None, name=None, id=None, parent_id=None, annotations=None, binary_annotations=None, debug=thrift_spec[9][4], timestamp=None, duration=None,): + self.trace_id = trace_id + self.name = name + self.id = id + self.parent_id = parent_id + self.annotations = annotations + self.binary_annotations = binary_annotations + self.debug = debug + self.timestamp = timestamp + self.duration = duration + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I64: + self.trace_id = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.name = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.I64: + self.id = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.I64: + self.parent_id = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.LIST: + self.annotations = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = Annotation() + _elem5.read(iprot) + self.annotations.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 8: + if ftype == TType.LIST: + self.binary_annotations = [] + (_etype9, _size6) = iprot.readListBegin() + for _i10 in range(_size6): + _elem11 = BinaryAnnotation() + _elem11.read(iprot) + self.binary_annotations.append(_elem11) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 9: + if ftype == TType.BOOL: + self.debug = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 10: + if ftype == TType.I64: + self.timestamp = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 11: + if ftype == TType.I64: + self.duration = iprot.readI64() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('Span') + if self.trace_id is not None: + oprot.writeFieldBegin('trace_id', TType.I64, 1) + oprot.writeI64(self.trace_id) + oprot.writeFieldEnd() + if self.name is not None: + oprot.writeFieldBegin('name', TType.STRING, 3) + oprot.writeString(self.name.encode('utf-8') if sys.version_info[0] == 2 else self.name) + oprot.writeFieldEnd() + if self.id is not None: + oprot.writeFieldBegin('id', TType.I64, 4) + oprot.writeI64(self.id) + oprot.writeFieldEnd() + if self.parent_id is not None: + oprot.writeFieldBegin('parent_id', TType.I64, 5) + oprot.writeI64(self.parent_id) + oprot.writeFieldEnd() + if self.annotations is not None: + oprot.writeFieldBegin('annotations', TType.LIST, 6) + oprot.writeListBegin(TType.STRUCT, len(self.annotations)) + for iter12 in self.annotations: + iter12.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.binary_annotations is not None: + oprot.writeFieldBegin('binary_annotations', TType.LIST, 8) + oprot.writeListBegin(TType.STRUCT, len(self.binary_annotations)) + for iter13 in self.binary_annotations: + iter13.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.debug is not None: + oprot.writeFieldBegin('debug', TType.BOOL, 9) + oprot.writeBool(self.debug) + oprot.writeFieldEnd() + if self.timestamp is not None: + oprot.writeFieldBegin('timestamp', TType.I64, 10) + oprot.writeI64(self.timestamp) + oprot.writeFieldEnd() + if self.duration is not None: + oprot.writeFieldBegin('duration', TType.I64, 11) + oprot.writeI64(self.duration) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class Response(object): - """ - Attributes: - - ok - """ - - thrift_spec = ( - None, # 0 - (1, TType.BOOL, 'ok', None, None, ), # 1 - ) - - def __init__(self, ok=None,): - self.ok = ok - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.BOOL: - self.ok = iprot.readBool() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('Response') - if self.ok is not None: - oprot.writeFieldBegin('ok', TType.BOOL, 1) - oprot.writeBool(self.ok) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - - def validate(self): - if self.ok is None: - raise TProtocol.TProtocolException(message='Required field ok is unset!') - return - - - def __hash__(self): - value = 17 - value = (value * 31) ^ hash(self.ok) - return value - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) + """ + Attributes: + - ok + """ + + thrift_spec = ( + None, # 0 + (1, TType.BOOL, 'ok', None, None, ), # 1 + ) + + def __init__(self, ok=None,): + self.ok = ok + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.BOOL: + self.ok = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('Response') + if self.ok is not None: + oprot.writeFieldBegin('ok', TType.BOOL, 1) + oprot.writeBool(self.ok) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.ok is None: + raise TProtocolException(message='Required field ok is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) diff --git a/jaeger_client/tracer.py b/jaeger_client/tracer.py index a84fab09..fea64261 100644 --- a/jaeger_client/tracer.py +++ b/jaeger_client/tracer.py @@ -26,6 +26,7 @@ import time import logging import random +import six import opentracing from opentracing import Format, UnsupportedFormatException from opentracing.ext import tags as ext_tags @@ -132,7 +133,7 @@ def start_span(self, if sampled: flags = SAMPLED_FLAG tags = tags or {} - for k, v in sampler_tags.iteritems(): + for k, v in six.iteritems(sampler_tags): tags[k] = v else: # have debug id flags = SAMPLED_FLAG | DEBUG_FLAG @@ -159,7 +160,7 @@ def start_span(self, if (rpc_server or not parent_id) and (flags & SAMPLED_FLAG): # this is a first-in-process span, and is sampled - for k, v in self.tags.iteritems(): + for k, v in six.iteritems(self.tags): span.set_tag(k, v) self._emit_span_metrics(span=span, join=rpc_server) diff --git a/jaeger_client/utils.py b/jaeger_client/utils.py index 3e7c97c3..1f329200 100644 --- a/jaeger_client/utils.py +++ b/jaeger_client/utils.py @@ -1,3 +1,6 @@ +from builtins import bytes +from builtins import range +from builtins import object # Copyright (c) 2016 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -74,7 +77,7 @@ def local_ip(): if ip.startswith('127.'): # Check eth0, eth1, eth2, en0, ... interfaces = [ - i + str(n) for i in ('eth', 'en', 'wlan') for n in xrange(3) + i + bytes(n) for i in (b'eth', b'en', b'wlan') for n in range(3) ] # :( for interface in interfaces: try: @@ -88,6 +91,7 @@ def local_ip(): def interface_ip(interface): """Determine the IP assigned to us by the given network interface.""" sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + return socket.inet_ntoa( fcntl.ioctl( sock.fileno(), 0x8915, struct.pack('256s', interface[:15]) diff --git a/setup.py b/setup.py index 4fbe022e..68555d55 100644 --- a/setup.py +++ b/setup.py @@ -33,12 +33,14 @@ 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.6' ], install_requires=[ + 'future', 'futures', + 'six', 'threadloop>=1,<2', - # we want thrift>=0.9.2.post1,<0.9.3, but we let the users pin to that - 'thrift', + 'thrift>=0.10.0', 'tornado>=4.3,<5', 'opentracing>=1.2.2,<1.3', ], diff --git a/tests/test_TUDPTransport.py b/tests/test_TUDPTransport.py index 2c67016f..b6a85f79 100644 --- a/tests/test_TUDPTransport.py +++ b/tests/test_TUDPTransport.py @@ -39,7 +39,7 @@ def test_constructor_nonblocking(self): assert t.transport_sock.gettimeout() == 0 def test_write(self): - self.t.write('hello') + self.t.write(b'hello') def test_isopen_when_open(self): assert self.t.isOpen() == True @@ -52,4 +52,4 @@ def test_close(self): self.t.close() with self.assertRaises(Exception): # Something bad should happen if we send on a closed socket.. - self.t.write('hello') + self.t.write(b'hello') diff --git a/tests/test_codecs.py b/tests/test_codecs.py index a45a98ab..fb70f7c3 100644 --- a/tests/test_codecs.py +++ b/tests/test_codecs.py @@ -84,8 +84,8 @@ def test_trace_context_from_to_string(self): from_string = span_context_from_string tests = [ - [(256L, 127L, None, 1), '100:7f:0:1'], - [(256L, 127L, 256L, 0), '100:7f:100:0'], + [(256, 127, None, 1), '100:7f:0:1'], + [(256, 127, 256, 0), '100:7f:100:0'], ] for test in tests: ctx = test[0] @@ -95,13 +95,13 @@ def test_trace_context_from_to_string(self): self.assertEqual(ctx_rev, ctx) ctx_rev = from_string(['100:7f:100:0']) - assert ctx_rev == (256L, 127L, 256L, 0), 'Array is acceptable' + assert ctx_rev == (256, 127, 256, 0), 'Array is acceptable' with self.assertRaises(SpanContextCorruptedException): from_string(['100:7f:100:0', 'garbage']) ctx_rev = from_string(u'100:7f:100:0') - assert ctx_rev == (256L, 127L, 256L, 0), 'Unicode is acceptable' + assert ctx_rev == (256, 127, 256, 0), 'Unicode is acceptable' def test_context_to_readable_headers(self): for url_encoding in [False, True]: @@ -215,14 +215,14 @@ def test_context_from_large_ids(self): 'Trace-ID': 'FFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFF:1', } context = codec.extract(headers) - assert context.trace_id == 0xFFFFFFFFFFFFFFFFL - assert context.trace_id == (1L << 64) - 1 + assert context.trace_id == 0xFFFFFFFFFFFFFFFF + assert context.trace_id == (1 << 64) - 1 assert context.trace_id > 0 - assert context.span_id == 0xFFFFFFFFFFFFFFFFL - assert context.span_id == (1L << 64) - 1 + assert context.span_id == 0xFFFFFFFFFFFFFFFF + assert context.span_id == (1 << 64) - 1 assert context.span_id > 0 - assert context.parent_id == 0xFFFFFFFFFFFFFFFFL - assert context.parent_id == (1L << 64) - 1 + assert context.parent_id == 0xFFFFFFFFFFFFFFFF + assert context.parent_id == (1 << 64) - 1 assert context.parent_id > 0 def test_zipkin_codec_extract(self): @@ -322,6 +322,6 @@ def test_debug_id(): span = tracer.start_span('test', child_of=context) assert span.is_debug() assert span.is_sampled() - tags = filter(lambda t: t.key == debug_header, span.tags) + tags = [t for t in span.tags if t.key == debug_header] assert len(tags) == 1 - assert tags[0].value == 'Coraline' + assert tags[0].value == b'Coraline' diff --git a/tests/test_crossdock.py b/tests/test_crossdock.py index dc1fe741..5d8e9c1d 100644 --- a/tests/test_crossdock.py +++ b/tests/test_crossdock.py @@ -19,6 +19,7 @@ # THE SOFTWARE. from __future__ import absolute_import +from builtins import str import mock import json diff --git a/tests/test_local_agent_net.py b/tests/test_local_agent_net.py index c7d31a58..7d5cdaff 100644 --- a/tests/test_local_agent_net.py +++ b/tests/test_local_agent_net.py @@ -1,10 +1,12 @@ +from future import standard_library +standard_library.install_aliases() import pytest import tornado.web -from urlparse import urlparse +from urllib.parse import urlparse from jaeger_client.local_agent_net import LocalAgentSender from jaeger_client.config import DEFAULT_REPORTING_PORT -test_strategy = """ +test_strategy = b""" { "strategyType":0, "probabilisticSampling": diff --git a/tests/test_rate_limiter.py b/tests/test_rate_limiter.py index 1709e10f..d40fe011 100644 --- a/tests/test_rate_limiter.py +++ b/tests/test_rate_limiter.py @@ -1,3 +1,4 @@ +from builtins import range # Copyright (c) 2017 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/tests/test_reporter.py b/tests/test_reporter.py index 24ff444a..fd0f6799 100644 --- a/tests/test_reporter.py +++ b/tests/test_reporter.py @@ -1,3 +1,6 @@ +from __future__ import print_function +from builtins import range +from builtins import object # Copyright (c) 2016 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -163,7 +166,7 @@ def _wait_for(self, fn): if fn(): return yield tornado.gen.sleep(0.001) - print 'waited for condition %f' % (time.time() - start) + print('waited for condition %f' % (time.time() - start)) @gen_test def test_submit_batch_size_1(self): diff --git a/tests/test_sampler.py b/tests/test_sampler.py index 8e4aa139..2a45fc3d 100644 --- a/tests/test_sampler.py +++ b/tests/test_sampler.py @@ -1,3 +1,6 @@ +from __future__ import division +from builtins import range +from past.utils import old_div # Copyright (c) 2016 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -36,7 +39,7 @@ get_rate_limit, ) -MAX_INT = 1L << 63 +MAX_INT = 1 << 63 def get_tags(type, param): return { @@ -61,7 +64,7 @@ def test_probabilistic_sampler_errors(): def test_probabilistic_sampler(): sampler = ProbabilisticSampler(0.5) - assert MAX_INT == 0x8000000000000000L + assert MAX_INT == 0x8000000000000000 sampled, tags = sampler.is_sampled(MAX_INT-10) assert sampled assert tags == get_tags('probabilistic', 0.5) @@ -161,17 +164,17 @@ def test_guaranteed_throughput_probabilistic_sampler(): assert tags == get_tags('lowerbound', 0.5) sampled, _ = sampler.is_sampled(MAX_INT+10) assert not sampled - assert '%s' % sampler == 'GuaranteedThroughputProbabilisticSampler(op, 0.5, 2)' + assert '%s' % sampler == 'GuaranteedThroughputProbabilisticSampler(op, 0.5, 2.0)' sampler.update(3, 0.51) sampled, tags = sampler.is_sampled(MAX_INT-10) assert sampled assert tags == get_tags('probabilistic', 0.51) - sampled, tags = sampler.is_sampled(MAX_INT+(MAX_INT/4)) + sampled, tags = sampler.is_sampled(MAX_INT+(old_div(MAX_INT,4))) assert sampled assert tags == get_tags('lowerbound', 0.51) - assert '%s' % sampler == 'GuaranteedThroughputProbabilisticSampler(op, 0.51, 3)' + assert '%s' % sampler == 'GuaranteedThroughputProbabilisticSampler(op, 0.51, 3.0)' sampler.close() @@ -198,7 +201,7 @@ def test_adaptive_sampler(): sampled, tags = sampler.is_sampled(MAX_INT-10, "new_op") assert sampled assert tags == get_tags('probabilistic', 0.51) - sampled, tags = sampler.is_sampled(MAX_INT+(MAX_INT/4), "new_op") + sampled, tags = sampler.is_sampled(MAX_INT+(old_div(MAX_INT,4)), "new_op") assert sampled assert tags == get_tags('lowerbound', 0.51) @@ -207,9 +210,9 @@ def test_adaptive_sampler(): sampled, tags = sampler.is_sampled(MAX_INT-10, "new_op_2") assert sampled assert tags == get_tags('probabilistic', 0.51) - sampled, _ = sampler.is_sampled(MAX_INT+(MAX_INT/4), "new_op_2") + sampled, _ = sampler.is_sampled(MAX_INT+(old_div(MAX_INT,4)), "new_op_2") assert not sampled - assert '%s' % sampler == 'AdaptiveSampler(0.51, 3, 2)' + assert '%s' % sampler == 'AdaptiveSampler(0.51, 3.0, 2)' # Update the strategies strategies = { @@ -242,7 +245,7 @@ def test_adaptive_sampler(): sampled, tags = sampler.is_sampled(MAX_INT-10, 'new_op_3') assert sampled assert tags == get_tags('probabilistic', 0.53) - assert '%s' % sampler == 'AdaptiveSampler(0.52, 4, 2)' + assert '%s' % sampler == 'AdaptiveSampler(0.52, 4.0, 2)' sampler.close() @@ -268,12 +271,12 @@ def test_adaptive_sampler_default_values(): } ] }) - assert '%s' % adaptive_sampler == 'AdaptiveSampler(0.001, 4, 2)' + assert '%s' % adaptive_sampler == 'AdaptiveSampler(0.001, 4.0, 2)' sampled, tags = adaptive_sampler.is_sampled(0, 'new_op') assert sampled assert tags == get_tags('probabilistic', 0.002) - assert '%s' % adaptive_sampler.samplers['new_op'] == 'GuaranteedThroughputProbabilisticSampler(new_op, 0.002, 4)' + assert '%s' % adaptive_sampler.samplers['new_op'] == 'GuaranteedThroughputProbabilisticSampler(new_op, 0.002, 4.0)' sampled, tags = adaptive_sampler.is_sampled(0, 'op') assert sampled @@ -395,7 +398,7 @@ def test_sampling_request_callback(): return_value.result = lambda *args: \ type('obj', (object,), {'body': adaptive_sampling_strategy})() sampler._sampling_request_callback(return_value) - assert '%s' % sampler.sampler == 'AdaptiveSampler(0.001, 2, 10)', 'sampler should have changed to adaptive' + assert '%s' % sampler.sampler == 'AdaptiveSampler(0.001, 2.0, 10)', 'sampler should have changed to adaptive' prev_sampler = sampler.sampler sampler._sampling_request_callback(return_value) @@ -552,7 +555,7 @@ def test_update_sampler_adaptive_sampler(): } remote_sampler._update_sampler(response) - assert '%s' % remote_sampler.sampler == 'AdaptiveSampler(0.001, 2, 10)' + assert '%s' % remote_sampler.sampler == 'AdaptiveSampler(0.001, 2.0, 10)' new_response = { "strategyType":1, @@ -573,7 +576,7 @@ def test_update_sampler_adaptive_sampler(): } remote_sampler._update_sampler(new_response) - assert '%s' % remote_sampler.sampler == 'AdaptiveSampler(0.51, 3, 10)' + assert '%s' % remote_sampler.sampler == 'AdaptiveSampler(0.51, 3.0, 10)' remote_sampler._update_sampler({"strategyType":0,"probabilisticSampling":{"samplingRate":0.004}}) assert '%s' % remote_sampler.sampler == 'ProbabilisticSampler(0.004)', \ diff --git a/tests/test_thrift.py b/tests/test_thrift.py index defb7748..e1983a65 100644 --- a/tests/test_thrift.py +++ b/tests/test_thrift.py @@ -1,3 +1,5 @@ +from future import standard_library +standard_library.install_aliases() # Copyright (c) 2016 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -from cStringIO import StringIO +from io import BytesIO import jaeger_client.thrift_gen.zipkincore.ZipkinCollector as zipkin_collector import jaeger_client.thrift_gen.sampling.SamplingManager as sampling_manager @@ -77,7 +79,7 @@ def now_reading(self): it's one or the other (really? yes.). This will convert us from write-able to read-able. """ - self._buffer = StringIO(self.getvalue()) + self._buffer = BytesIO(self.getvalue()) spans = thrift.make_zipkin_spans([span]) @@ -120,8 +122,8 @@ def serialize(span_id): trace_id = 0x97fd53dc6b437681 serialize(trace_id) - trace_id = (1L << 64) - 1 - assert trace_id == 0xffffffffffffffffL + trace_id = (1 << 64) - 1 + assert trace_id == 0xffffffffffffffff serialize(trace_id) assert thrift.id_to_int(trace_id) == -1 diff --git a/tests/test_tracer.py b/tests/test_tracer.py index efe9d8d7..3856936a 100644 --- a/tests/test_tracer.py +++ b/tests/test_tracer.py @@ -21,6 +21,7 @@ import mock import random +import six import pytest import tornado.httputil @@ -29,19 +30,19 @@ from jaeger_client import ConstSampler, Tracer from jaeger_client import constants as c from jaeger_client.thrift_gen.zipkincore import constants as g -from jaeger_client.thrift import add_zipkin_annotations +from jaeger_client.thrift import add_zipkin_annotations, str_to_binary def log_exists(span, value): - return filter(lambda (x): x.value == value, span.logs) != [] + return [x for x in span.logs if x.value == value] != [] def test_start_trace(tracer): assert type(tracer) is Tracer with mock.patch.object(random.Random, 'getrandbits') as mock_random, \ mock.patch('time.time') as mock_timestamp: - mock_random.return_value = 12345L - mock_timestamp.return_value = 54321L + mock_random.return_value = 12345 + mock_timestamp.return_value = 54321 span = tracer.start_span('test') span.set_tag(ext_tags.SPAN_KIND, ext_tags.SPAN_KIND_RPC_SERVER) @@ -49,10 +50,10 @@ def test_start_trace(tracer): assert span.tracer == tracer, "Tracer must be referenced from span" assert span.kind == ext_tags.SPAN_KIND_RPC_SERVER, \ 'Span must be server-side' - assert span.trace_id == 12345L, "Must match trace_id" + assert span.trace_id == 12345, "Must match trace_id" assert span.is_sampled(), "Must be sampled" assert span.parent_id is None, "Must not have parent_id (root span)" - assert span.start_time == 54321L, "Must match timestamp" + assert span.start_time == 54321, "Must match timestamp" span.finish() assert span.end_time is not None, "Must have end_time defined" @@ -224,7 +225,7 @@ def test_tracer_tags_on_root_span(span_type, expected_tags): 'child', child_of=span.context, tags={ext_tags.SPAN_KIND: ext_tags.SPAN_KIND_RPC_SERVER} ) - for key, value in expected_tags.iteritems(): + for key, value in six.iteritems(expected_tags): found_tag = None for tag in span.tags: if tag.key == key: @@ -236,7 +237,7 @@ def test_tracer_tags_on_root_span(span_type, expected_tags): assert found_tag is not None, 'test (%s): expecting tag %s' % ( span_type, key ) - assert found_tag.value == value, \ + assert found_tag.value == str_to_binary(value), \ 'test (%s): expecting tag %s=%s' % (span_type, key, value) diff --git a/tests/test_tracer_benchmark.py b/tests/test_tracer_benchmark.py index e919409f..30886fd5 100644 --- a/tests/test_tracer_benchmark.py +++ b/tests/test_tracer_benchmark.py @@ -1,3 +1,4 @@ +from builtins import range # Copyright (c) 2016 Uber Technologies, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy