Skip to content

Commit 1777387

Browse files
committed
use threading instead of thread for consistency and compatibility 2->3
1 parent a4f8a7a commit 1777387

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

instana/meter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import threading as t
2-
import thread
32
import instana.log as l
43
import resource
54
import os
@@ -99,8 +98,7 @@ def process(self):
9998
m = self.collect_metrics()
10099
d = EntityData(pid=os.getpid(), snapshot=s, metrics=m)
101100

102-
thread.start_new_thread(self.sensor.agent.request,
103-
(self.sensor.agent.make_url(a.AGENT_DATA_URL), "POST", d))
101+
t.Thread(self.sensor.agent.request, args=(self.sensor.agent.make_url(a.AGENT_DATA_URL), "POST", d)).start()
104102

105103
self.tick()
106104

instana/recorder.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from basictracer import Sampler, SpanRecorder
22
import instana.agent_const as a
3-
import thread
3+
import threading as t
44

55
class InstanaSpan(object):
66
t = 0
@@ -29,19 +29,16 @@ def record_span(self, span):
2929
if not data.service:
3030
data.service = self.sensor.service_name
3131

32-
thread.start_new_thread(self.sensor.agent.request,
33-
(self.sensor.agent.make_url(a.AGENT_TRACES_URL), "POST",
34-
[InstanaSpan(t=span.context.trace_id,
35-
p=span.parent_id,
36-
s=span.context.span_id,
37-
ts=int(
38-
round(span.start_time * 1000)),
39-
d=int(
40-
round(span.duration * 1000)),
41-
n=self.get_string_span_log_field(
42-
span, "type"),
43-
f=self.sensor.agent.from_,
44-
data=data)]))
32+
t.Thread(self.sensor.agent.request,
33+
args=(self.sensor.agent.make_url(a.AGENT_TRACES_URL), "POST",
34+
[InstanaSpan(t=span.context.trace_id,
35+
p=span.parent_id,
36+
s=span.context.span_id,
37+
ts=int(round(span.start_time * 1000)),
38+
d=int(round(span.duration * 1000)),
39+
n=self.get_string_span_log_field(span, "type"),
40+
f=self.sensor.agent.from_,
41+
data=data)])).start()
4542

4643
def get_string_span_log_field(self, span, field):
4744
ret = self.get_span_log_field(span, field)

0 commit comments

Comments
 (0)