Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.

Commit 91694d3

Browse files
authored
Remove six usage (#310)
Signed-off-by: George Leman <[email protected]>
1 parent ec2ed1c commit 91694d3

File tree

14 files changed

+25
-43
lines changed

14 files changed

+25
-43
lines changed

jaeger_client/codecs.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
from .span_context import SpanContext
3030
from .constants import SAMPLED_FLAG, DEBUG_FLAG
3131

32-
import six
33-
from six.moves import urllib_parse
32+
import urllib.parse
3433

3534

3635
class Codec(object):
@@ -65,14 +64,14 @@ def inject(self, span_context, carrier):
6564
parent_id=span_context.parent_id, flags=span_context.flags)
6665
baggage = span_context.baggage
6766
if baggage:
68-
for key, value in six.iteritems(baggage):
67+
for key, value in baggage.items():
6968
encoded_key = key
70-
if isinstance(key, six.binary_type):
69+
if isinstance(key, (bytes,)):
7170
encoded_key = str(key, 'utf-8')
7271
if self.url_encoding:
73-
encoded_value = urllib_parse.quote(value)
72+
encoded_value = urllib.parse.quote(value)
7473
else:
75-
if isinstance(value, six.binary_type):
74+
if isinstance(key, (bytes,)):
7675
encoded_value = str(value, 'utf-8')
7776
else:
7877
encoded_value = value
@@ -87,28 +86,28 @@ def extract(self, carrier):
8786
trace_id, span_id, parent_id, flags = None, None, None, None
8887
baggage = None
8988
debug_id = None
90-
for key, value in six.iteritems(carrier):
89+
for key, value in carrier.items():
9190
uc_key = key.lower()
9291
if uc_key == self.trace_id_header:
9392
if self.url_encoding:
94-
value = urllib_parse.unquote(value)
93+
value = urllib.parse.unquote(value)
9594
trace_id, span_id, parent_id, flags = \
9695
span_context_from_string(value)
9796
elif uc_key.startswith(self.baggage_prefix):
9897
if self.url_encoding:
99-
value = urllib_parse.unquote(value)
98+
value = urllib.parse.unquote(value)
10099
attr_key = key[self.prefix_length:]
101100
if baggage is None:
102101
baggage = {attr_key.lower(): value}
103102
else:
104103
baggage[attr_key.lower()] = value
105104
elif uc_key == self.debug_id_header:
106105
if self.url_encoding:
107-
value = urllib_parse.unquote(value)
106+
value = urllib.parse.unquote(value)
108107
debug_id = value
109108
elif uc_key == self.baggage_header:
110109
if self.url_encoding:
111-
value = urllib_parse.unquote(value)
110+
value = urllib.parse.unquote(value)
112111
baggage = self._parse_baggage_header(value, baggage)
113112
if not trace_id or not span_id:
114113
# reset all IDs
@@ -235,7 +234,7 @@ def span_context_from_string(value):
235234
raise SpanContextCorruptedException(
236235
'trace context must be a string or array of 1: "%s"' % value)
237236
value = value[0]
238-
if not isinstance(value, six.string_types):
237+
if not isinstance(value, (str,)):
239238
raise SpanContextCorruptedException(
240239
'trace context not a string "%s"' % value)
241240
parts = value.split(':')
@@ -307,7 +306,7 @@ def extract(self, carrier):
307306

308307

309308
def header_to_hex(header):
310-
if not isinstance(header, (str, six.text_type)):
309+
if not isinstance(header, (str,)):
311310
raise SpanContextCorruptedException(
312311
'malformed trace context "%s", expected hex string' % header)
313312

@@ -352,7 +351,7 @@ def extract(self, carrier):
352351
raise InvalidCarrierException('carrier not a dictionary')
353352
trace_id = span_id = parent_id = None
354353
flags = 0x00
355-
for header_key, header_value in six.iteritems(carrier):
354+
for header_key, header_value in carrier.items():
356355
if header_value is None:
357356
continue
358357
lower_key = header_key.lower()

jaeger_client/constants.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from . import __version__
1818

19-
import six
2019

2120
# DEPRECATED: max number of bits to use when generating random ID
2221
MAX_ID_BITS = 64
@@ -34,10 +33,10 @@
3433
DEFAULT_FLUSH_INTERVAL = 1
3534

3635
# Name of the HTTP header used to encode trace ID
37-
TRACE_ID_HEADER = 'uber-trace-id' if six.PY3 else b'uber-trace-id'
36+
TRACE_ID_HEADER = 'uber-trace-id'
3837

3938
# Prefix for HTTP headers used to record baggage items
40-
BAGGAGE_HEADER_PREFIX = 'uberctx-' if six.PY3 else b'uberctx-'
39+
BAGGAGE_HEADER_PREFIX = 'uberctx-'
4140

4241
# The name of HTTP header or a TextMap carrier key which, if found in the
4342
# carrier, forces the trace to be sampled as "debug" trace. The value of the

jaeger_client/metrics/metrics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from __future__ import absolute_import
1616
from __future__ import division
1717

18-
import six
19-
2018

2119
class MetricsFactory(object):
2220
"""Generates new metrics."""
@@ -90,7 +88,7 @@ def _get_key(self, name, tags=None):
9088
if not tags:
9189
return name
9290
key = name
93-
for k in sorted(six.iterkeys(tags)):
91+
for k in sorted(tags.keys()):
9492
key = key + '.' + str(k) + '_' + str(tags[k])
9593
return key
9694

jaeger_client/sampler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import json
1818
import logging
1919
import random
20-
import six
2120

2221
from threading import Lock
2322
from tornado.ioloop import PeriodicCallback
@@ -316,7 +315,7 @@ def update(self, strategies):
316315
ProbabilisticSampler(self.default_sampling_probability)
317316

318317
def close(self):
319-
for _, sampler in six.iteritems(self.samplers):
318+
for _, sampler in self.samplers.items():
320319
sampler.close()
321320

322321
def __str__(self):

jaeger_client/span.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from __future__ import absolute_import
1616

17-
import six
1817
import threading
1918
import time
2019
import logging
@@ -47,7 +46,7 @@ def __init__(self, context, tracer, operation_name,
4746
self.tags = []
4847
self.logs = []
4948
if tags:
50-
for k, v in six.iteritems(tags):
49+
for k, v in tags.items():
5150
self.set_tag(k, v)
5251

5352
def set_operation_name(self, operation_name):

jaeger_client/thrift.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import traceback
16-
import six
1716
from opentracing.tracer import ReferenceType
1817
from .constants import MAX_TRACEBACK_LENGTH
1918

@@ -25,9 +24,6 @@
2524
_max_signed_id = (1 << 63) - 1
2625
_max_unsigned_id = (1 << 64)
2726

28-
if six.PY3:
29-
long = int
30-
3127

3228
def _id_to_low(big_id):
3329
"""
@@ -147,20 +143,20 @@ def _make_bool_tag(key, value):
147143

148144
def timestamp_micros(ts):
149145
"""
150-
Convert a float Unix timestamp from time.time() into a long value
146+
Convert a float Unix timestamp from time.time() into a int value
151147
in microseconds, as required by Zipkin protocol.
152148
:param ts:
153149
:return:
154150
"""
155-
return long(ts * 1000000)
151+
return int(ts * 1000000)
156152

157153

158154
def make_tags(tags, max_length, max_traceback_length):
159155
# TODO extend to support non-string tag values
160156
return [
161157
make_tag(key=k, value=v, max_length=max_length,
162158
max_traceback_length=max_traceback_length)
163-
for k, v in six.iteritems(tags or {})
159+
for k, v in (tags or {}).items()
164160
]
165161

166162

jaeger_client/tracer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import random
2222
import sys
2323
import time
24-
import six
2524
import opentracing
2625
from opentracing import Format, UnsupportedFormatException
2726
from opentracing.ext import tags as ext_tags
@@ -183,7 +182,7 @@ def start_span(self,
183182
if sampled:
184183
flags = SAMPLED_FLAG
185184
tags = tags or {}
186-
for k, v in six.iteritems(sampler_tags):
185+
for k, v in sampler_tags.items():
187186
tags[k] = v
188187
elif parent.debug_id and self.is_debug_allowed(operation_name):
189188
flags = SAMPLED_FLAG | DEBUG_FLAG

jaeger_client/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import struct
1717

1818
import time
19-
from six.moves import range
2019

2120

2221
class ErrorReporter(object):

tests/test_codecs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import unittest
1818
from collections import namedtuple
1919
from itertools import product
20-
import six
2120

2221
import mock
2322
import pytest
@@ -137,7 +136,7 @@ def test_context_to_readable_headers(self):
137136
'trace-attr-key2': 'cafe',
138137
'trace-attr-key3': '%F0%9F%91%BE',
139138
}, 'with url_encoding = %s' % url_encoding
140-
for key, val in six.iteritems(carrier):
139+
for key, val in carrier.items():
141140
assert isinstance(key, str)
142141
assert isinstance(val, str), '%s' % type(val)
143142
else:
@@ -522,7 +521,7 @@ def _test_baggage_without_trace_id(tracer, trace_id_header, baggage_header_prefi
522521
span = tracer.start_span('test', child_of=span_context)
523522
assert span.context.baggage == match
524523
# also check baggage through API
525-
for k, v in six.iteritems(match):
524+
for k, v in match.items():
526525
assert span.get_baggage_item(k) == v
527526

528527

tests/test_rate_limiter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from six.moves import range
1615
import time
1716
import mock
1817

0 commit comments

Comments
 (0)