Skip to content

Conversation

@SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/jaeger-client-python master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -143 to +146
self._processMap = {}
self._processMap["startTrace"] = Processor.process_startTrace
self._processMap["joinTrace"] = Processor.process_joinTrace
self._processMap = {
"startTrace": Processor.process_startTrace,
"joinTrace": Processor.process_joinTrace,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.__init__ refactored with the following changes:

Comment on lines -149 to +160
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:
if name in self._processMap:
return self._processMap[name](self, seqid, iprot, oprot)

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.process refactored with the following changes:

Comment on lines -211 to +214
if fid == 1:
if ftype == TType.STRUCT:
self.request = StartTraceRequest()
self.request.read(iprot)
else:
iprot.skip(ftype)
if fid == 1 and ftype == TType.STRUCT:
self.request = StartTraceRequest()
self.request.read(iprot)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function startTrace_args.read refactored with the following changes:

iprot.skip(ftype)
if fid == 0 and ftype == TType.STRUCT:
self.success = TraceResponse()
self.success.read(iprot)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function startTrace_result.read refactored with the following changes:

Comment on lines -342 to +339
if fid == 1:
if ftype == TType.STRUCT:
self.request = JoinTraceRequest()
self.request.read(iprot)
else:
iprot.skip(ftype)
if fid == 1 and ftype == TType.STRUCT:
self.request = JoinTraceRequest()
self.request.read(iprot)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function joinTrace_args.read refactored with the following changes:

for key in tags.keys():
tag_name_list.append(key)
return tag_name_list
return [key for key in tags.keys()]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PrometheusMetricsFactory._get_tag_name_list refactored with the following changes:

Comment on lines -113 to +116
self._processMap = {}
self._processMap["emitZipkinBatch"] = Processor.process_emitZipkinBatch
self._processMap["emitBatch"] = Processor.process_emitBatch
self._processMap = {
"emitZipkinBatch": Processor.process_emitZipkinBatch,
"emitBatch": Processor.process_emitBatch,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.__init__ refactored with the following changes:

Comment on lines -119 to +130
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:
if name in self._processMap:
return self._processMap[name](self, seqid, iprot, oprot)

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.process refactored with the following changes:

Comment on lines -171 to +179
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)
if fid == 1 and 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()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function emitZipkinBatch_args.read refactored with the following changes:

iprot.skip(ftype)
if fid == 1 and ftype == TType.STRUCT:
self.batch = jaeger.ttypes.Batch()
self.batch.read(iprot)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function emitBatch_args.read refactored with the following changes:

self._handler = handler
self._processMap = {}
self._processMap["submitBatches"] = Processor.process_submitBatches
self._processMap = {"submitBatches": Processor.process_submitBatches}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.__init__ refactored with the following changes:

Comment on lines -111 to +120
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:
if name in self._processMap:
return self._processMap[name](self, seqid, iprot, oprot)

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.process refactored with the following changes:

Comment on lines -161 to +167
if fid == 1:
if ftype == TType.LIST:
self.batches = []
(_etype45, _size42) = iprot.readListBegin()
for _i46 in xrange(_size42):
_elem47 = Batch()
_elem47.read(iprot)
self.batches.append(_elem47)
iprot.readListEnd()
else:
iprot.skip(ftype)
if fid == 1 and ftype == TType.LIST:
self.batches = []
(_etype45, _size42) = iprot.readListBegin()
for _i46 in xrange(_size42):
_elem47 = Batch()
_elem47.read(iprot)
self.batches.append(_elem47)
iprot.readListEnd()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function submitBatches_args.read refactored with the following changes:

Comment on lines -234 to +237
if fid == 0:
if ftype == TType.LIST:
self.success = []
(_etype52, _size49) = iprot.readListBegin()
for _i53 in xrange(_size49):
_elem54 = BatchSubmitResponse()
_elem54.read(iprot)
self.success.append(_elem54)
iprot.readListEnd()
else:
iprot.skip(ftype)
if fid == 0 and ftype == TType.LIST:
self.success = []
(_etype52, _size49) = iprot.readListBegin()
for _i53 in xrange(_size49):
_elem54 = BatchSubmitResponse()
_elem54.read(iprot)
self.success.append(_elem54)
iprot.readListEnd()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function submitBatches_result.read refactored with the following changes:

Comment on lines -232 to +243
if fid == 1:
if ftype == TType.I64:
self.timestamp = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.LIST:
self.fields = []
(_etype3, _size0) = iprot.readListBegin()
for _i4 in xrange(_size0):
_elem5 = Tag()
_elem5.read(iprot)
self.fields.append(_elem5)
iprot.readListEnd()
else:
iprot.skip(ftype)
else:
if fid == 1 and ftype == TType.I64:
self.timestamp = iprot.readI64()
elif ftype != TType.LIST or fid != 2:
iprot.skip(ftype)
else:
self.fields = []
(_etype3, _size0) = iprot.readListBegin()
for _i4 in xrange(_size0):
_elem5 = Tag()
_elem5.read(iprot)
self.fields.append(_elem5)
iprot.readListEnd()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Log.read refactored with the following changes:

self._handler = handler
self._processMap = {}
self._processMap["submitZipkinBatch"] = Processor.process_submitZipkinBatch
self._processMap = {"submitZipkinBatch": Processor.process_submitZipkinBatch}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.__init__ refactored with the following changes:

Comment on lines -111 to +120
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:
if name in self._processMap:
return self._processMap[name](self, seqid, iprot, oprot)

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Processor.process refactored with the following changes:

Comment on lines -161 to +167
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)
if fid == 1 and 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()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function submitZipkinBatch_args.read refactored with the following changes:

Comment on lines -234 to +237
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)
if fid == 0 and 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()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function submitZipkinBatch_result.read refactored with the following changes:

Comment on lines -653 to +654
if fid == 1:
if ftype == TType.BOOL:
self.ok = iprot.readBool()
else:
iprot.skip(ftype)
if fid == 1 and ftype == TType.BOOL:
self.ok = iprot.readBool()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Response.read refactored with the following changes:

Comment on lines -170 to +174
good_headers_bad_values = {
'Trace-ID': '100:7f:0:1xxx',
'trace-attr-Kiff': 'Amy'
}
with self.assertRaises(SpanContextCorruptedException):
good_headers_bad_values = {
'Trace-ID': '100:7f:0:1xxx',
'trace-attr-Kiff': 'Amy'
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestCodecs.test_context_from_bad_readable_headers refactored with the following changes:

Comment on lines -191 to +202
codec = tracer.codecs[Format.HTTP_HEADERS]
headers = {
'Trace-ID': '100%3A7f:0:1',
'trace-attr-Kiff': 'Amy%20Wang',
'trace-atTR-HERMES': 'LaBarbara%20Hermes'
}
else:
codec = tracer.codecs[Format.HTTP_HEADERS]
headers = {
'Trace-ID': '100:7f:0:1',
'trace-attr-Kiff': 'Amy Wang',
'trace-atTR-HERMES': 'LaBarbara Hermes'
}
codec = tracer.codecs[Format.HTTP_HEADERS]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestCodecs.test_context_from_readable_headers refactored with the following changes:

Comment on lines -499 to +498
carrier = dict()
carrier = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_inject_with_128bit_trace_id refactored with the following changes:

Comment on lines -85 to +108
level3 = dict()
level3['serviceName'] = 'python'
level3['serverRole'] = 's3'
level3['transport'] = s3_transport
level3['host'] = 'localhost'
level3['port'] = str(http_port) if s3_transport == 'HTTP' else tchannel_port

level2 = dict()
level2['serviceName'] = 'python'
level2['serverRole'] = 's2'
level2['transport'] = s2_transport
level2['host'] = 'localhost'
level2['port'] = str(http_port) if s2_transport == 'HTTP' else tchannel_port
level2['downstream'] = level3

level1 = dict()
level1['baggage'] = 'Zoidberg'
level1['serverRole'] = 's1'
level1['sampled'] = sampled
level1['downstream'] = level2
level3 = {
'serviceName': 'python',
'serverRole': 's3',
'transport': s3_transport,
'host': 'localhost',
'port': str(http_port) if s3_transport == 'HTTP' else tchannel_port,
}

level2 = {
'serviceName': 'python',
'serverRole': 's2',
'transport': s2_transport,
'host': 'localhost',
'port': str(http_port) if s2_transport == 'HTTP' else tchannel_port,
'downstream': level3,
}

level1 = {
'baggage': 'Zoidberg',
'serverRole': 's1',
'sampled': sampled,
'downstream': level2,
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_trace_propagation refactored with the following changes:

Comment on lines -137 to +141
payload = dict()
payload['operation'] = 'Zoidberg'
payload['count'] = 2
payload['tags'] = {'key': 'value'}
payload = {'operation': 'Zoidberg', 'count': 2, 'tags': {'key': 'value'}}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_endtoend_handler refactored with the following changes:

sampler.rate_limiter.last_tick = ts
with mock.patch('jaeger_client.rate_limiter.RateLimiter.timestamp') \
as mock_time:
as mock_time:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_rate_limiting_sampler refactored with the following changes:

Comment on lines -124 to +126
args=args if args else [],
args=args or [],
expected=expected,
kwargs=kwargs if kwargs else {},
kwargs=kwargs or {},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_span_logging.test refactored with the following changes:

Comment on lines -203 to +205
span = 'span'
carrier = {}
with pytest.raises(ValueError):
span = 'span'
carrier = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_serialization_error refactored with the following changes:

Comment on lines -290 to +295
codecs = {
'extra_codec': 'codec_placeholder',
Format.BINARY: 'overridden_binary_codec'

}
with mock.patch('socket.gethostname', return_value='dream-host.com'):
codecs = {
'extra_codec': 'codec_placeholder',
Format.BINARY: 'overridden_binary_codec'

}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_tracer_override_codecs refactored with the following changes:


def _generate_spans(tracer, iterations=1000, sleep=None):
for i in range(0, iterations):
for _ in range(iterations):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _generate_spans refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant