Skip to content

Commit a4f8a7a

Browse files
committed
post-linter
1 parent a7db760 commit a4f8a7a

File tree

7 files changed

+40
-54
lines changed

7 files changed

+40
-54
lines changed

example/simple.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,29 @@
88
import instana.data as d
99
import instana.http as h
1010

11+
1112
def main(argv):
1213
instana.tracer.init(o.Options(service='python-simple',
13-
log_level=logging.DEBUG))
14+
log_level=logging.DEBUG))
1415

1516
while (True):
1617
simple()
1718

19+
1820
def simple():
1921
parent_span = ot.tracer.start_span(operation_name="parent")
2022
parent_span.log_kv({"type": h.HTTP_SERVER,
2123
"data": d.Data(http=h.HttpData(host="localhost",
22-
url="/python/simple/one",
23-
status=200,
24-
method="GET"))})
25-
child_span = ot.tracer.start_span(operation_name="child", child_of=parent_span)
24+
url="/python/simple/one",
25+
status=200,
26+
method="GET"))})
27+
child_span = ot.tracer.start_span(
28+
operation_name="child", child_of=parent_span)
2629
child_span.log_kv({"type": h.HTTP_CLIENT,
2730
"data": d.Data(http=h.HttpData(host="localhost",
28-
url="/python/simple/two",
29-
status=204,
30-
method="POST"))})
31+
url="/python/simple/two",
32+
status=204,
33+
method="POST"))})
3134
child_span.set_baggage_item("someBaggage", "someValue")
3235
time.sleep(.45)
3336
child_span.finish()

instana/agent.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import thread
32
import urllib2
43
import instana.log as l
54
import instana.fsm as f

instana/fsm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_default_gateway(self):
8484
def check_host(self, host):
8585
l.debug("checking host", host)
8686

87-
(b, h) = self.agent.request_header(
87+
(_, h) = self.agent.request_header(
8888
self.agent.make_host_url(host, "/"), "GET", "Server")
8989

9090
return h
@@ -96,7 +96,7 @@ def announce_sensor(self, e):
9696
name=sys.executable,
9797
args=sys.argv[0:])
9898

99-
(b, h) = self.agent.request_response(
99+
(b, _) = self.agent.request_response(
100100
self.agent.make_url(a.AGENT_DISCOVERY_URL), "PUT", d)
101101
if not b:
102102
l.error("Cannot announce sensor. Scheduling retry.")
@@ -105,13 +105,13 @@ def announce_sensor(self, e):
105105
self.agent.set_from(b)
106106
self.fsm.announce()
107107

108-
def schedule_retry(self, f, e):
109-
t.Timer(self.RETRY_PERIOD, f, [e]).start()
108+
def schedule_retry(self, fun, e):
109+
t.Timer(self.RETRY_PERIOD, fun, [e]).start()
110110

111111
def test_agent(self, e):
112112
l.debug("testing communication with the agent")
113113

114-
(b, h) = self.agent.head(self.agent.make_url(a.AGENT_DATA_URL))
114+
(b, _) = self.agent.head(self.agent.make_url(a.AGENT_DATA_URL))
115115

116116
if not b:
117117
self.schedule_retry(self.test_agent, e)

instana/log.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ def init(level):
1212

1313

1414
def debug(s, *args):
15-
logger.debug("%s %s" % (s, ' '.join(args)))
15+
logger.debug("%s %s", s, ' '.join(args))
1616

1717

1818
def info(s, *args):
19-
logger.info("%s %s" % (s, ' '.join(args)))
19+
logger.info("%s %s", s, ' '.join(args))
2020

2121

2222
def warn(s, *args):
23-
logger.warn("%s %s" % (s, ' '.join(args)))
23+
logger.warn("%s %s", s, ' '.join(args))
2424

2525

2626
def error(s, *args):
27-
logger.error("%s %s" % (s, ' '.join(args)))
27+
logger.error("%s %s", s, ' '.join(args))

instana/meter.py

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import instana.log as l
44
import resource
55
import os
6-
import gc
6+
import gc as gc_
77
import sys
88
import instana.agent_const as a
99

@@ -153,9 +153,9 @@ def collect_modules(self):
153153

154154
def collect_metrics(self):
155155
u = resource.getrusage(resource.RUSAGE_SELF)
156-
if gc.isenabled():
157-
c = list(gc.get_count())
158-
th = list(gc.get_threshold())
156+
if gc_.isenabled():
157+
c = list(gc_.get_count())
158+
th = list(gc_.get_threshold())
159159
g = GC(collect0=c[0] if not self.last_collect else c[0] - self.last_collect[0],
160160
collect1=c[1] if not self.last_collect else c[
161161
1] - self.last_collect[1],
@@ -166,45 +166,33 @@ def collect_metrics(self):
166166
threshold2=th[2])
167167

168168
thr = t.enumerate()
169-
daemon_threads = len(map(lambda tr: tr.daemon and tr.is_alive(), thr))
170-
alive_threads = len(
171-
map(lambda tr: not tr.daemon and tr.is_alive(), thr))
172-
dead_threads = len(map(lambda tr: not tr.is_alive(), thr))
169+
daemon_threads = len([tr.daemon and tr.is_alive() for tr in thr])
170+
alive_threads = len([not tr.daemon and tr.is_alive() for tr in thr])
171+
dead_threads = len([not tr.is_alive() for tr in thr])
173172

174173
m = Metrics(ru_utime=u[0] if not self.last_usage else u[0] - self.last_usage[0],
175-
ru_stime=u[1] if not self.last_usage else u[
176-
1] - self.last_usage[1],
174+
ru_stime=u[1] if not self.last_usage else u[1] - self.last_usage[1],
177175
ru_maxrss=u[2],
178176
ru_ixrss=u[3],
179177
ru_idrss=u[4],
180178
ru_isrss=u[5],
181-
ru_minflt=u[6] if not self.last_usage else u[
182-
6] - self.last_usage[6],
183-
ru_majflt=u[7] if not self.last_usage else u[
184-
7] - self.last_usage[7],
185-
ru_nswap=u[8] if not self.last_usage else u[
186-
8] - self.last_usage[8],
187-
ru_inblock=u[9] if not self.last_usage else u[
188-
9] - self.last_usage[9],
189-
ru_oublock=u[10] if not self.last_usage else u[
190-
10] - self.last_usage[10],
191-
ru_msgsnd=u[11] if not self.last_usage else u[
192-
11] - self.last_usage[11],
193-
ru_msgrcv=u[12] if not self.last_usage else u[
194-
12] - self.last_usage[12],
195-
ru_nsignals=u[13] if not self.last_usage else u[
196-
13] - self.last_usage[13],
197-
ru_nvcs=u[14] if not self.last_usage else u[
198-
14] - self.last_usage[14],
199-
ru_nivcsw=u[15] if not self.last_usage else u[
200-
15] - self.last_usage[15],
179+
ru_minflt=u[6] if not self.last_usage else u[6] - self.last_usage[6],
180+
ru_majflt=u[7] if not self.last_usage else u[7] - self.last_usage[7],
181+
ru_nswap=u[8] if not self.last_usage else u[8] - self.last_usage[8],
182+
ru_inblock=u[9] if not self.last_usage else u[9] - self.last_usage[9],
183+
ru_oublock=u[10] if not self.last_usage else u[10] - self.last_usage[10],
184+
ru_msgsnd=u[11] if not self.last_usage else u[11] - self.last_usage[11],
185+
ru_msgrcv=u[12] if not self.last_usage else u[12] - self.last_usage[12],
186+
ru_nsignals=u[13] if not self.last_usage else u[13] - self.last_usage[13],
187+
ru_nvcs=u[14] if not self.last_usage else u[14] - self.last_usage[14],
188+
ru_nivcsw=u[15] if not self.last_usage else u[15] - self.last_usage[15],
201189
alive_threads=alive_threads,
202190
dead_threads=dead_threads,
203191
daemon_threads=daemon_threads,
204192
gc=g)
205193

206194
self.last_usage = u
207-
if gc.isenabled():
195+
if gc_.isenabled():
208196
self.last_collect = c
209197

210198
return m

instana/options.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import instana.log as l
21
import logging
32

43

instana/recorder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from basictracer import Sampler, SpanRecorder
2-
import instana.log as l
32
import instana.agent_const as a
43
import thread
5-
import time
6-
74

85
class InstanaSpan(object):
96
t = 0
@@ -63,5 +60,5 @@ def get_span_log_field(self, span, field):
6360

6461
class InstanaSampler(Sampler):
6562

66-
def sampled(self, trace_id):
63+
def sampled(self, _):
6764
return False

0 commit comments

Comments
 (0)