Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions instana/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def announce(self, discovery):
headers={"Content-Type": "application/json"},
timeout=0.8)

if response.status_code is 200:
if response.status_code == 200:
self.last_seen = datetime.now()
except (requests.ConnectTimeout, requests.ConnectionError):
logger.debug("announce", exc_info=True)
Expand All @@ -175,7 +175,7 @@ def is_agent_ready(self):
try:
response = self.client.head(self.__data_url(), timeout=0.8)

if response.status_code is 200:
if response.status_code == 200:
return True
return False
except (requests.ConnectTimeout, requests.ConnectionError):
Expand All @@ -194,7 +194,7 @@ def report_data(self, entity_data):

# logger.warn("report_data: response.status_code is %s" % response.status_code)

if response.status_code is 200:
if response.status_code == 200:
self.last_seen = datetime.now()
except (requests.ConnectTimeout, requests.ConnectionError):
logger.debug("report_data: Instana host agent connection error")
Expand All @@ -219,7 +219,7 @@ def report_traces(self, spans):

# logger.warn("report_traces: response.status_code is %s" % response.status_code)

if response.status_code is 200:
if response.status_code == 200:
self.last_seen = datetime.now()
except (requests.ConnectTimeout, requests.ConnectionError):
logger.debug("report_traces: Instana host agent connection error")
Expand Down
2 changes: 1 addition & 1 deletion instana/fsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def announce_sensor(self, e):

response = self.agent.announce(d)

if response and (response.status_code is 200) and (len(response.content) > 2):
if response and (response.status_code == 200) and (len(response.content) > 2):
self.agent.set_from(response.content)
self.fsm.pending()
logger.debug("Announced pid: %s (true pid: %s). Waiting for Agent Ready...", str(pid), str(self.agent.from_.pid))
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/aiohttp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def stan_middleware(request, handler):
if 500 <= response.status <= 511:
scope.span.set_tag("error", True)
ec = scope.span.tags.get('ec', 0)
if ec is 0:
if ec == 0:
scope.span.set_tag("ec", ec + 1)

scope.span.set_tag("http.status_code", response.status)
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def process_response(self, request, response):
if 500 <= response.status_code <= 511:
request.iscope.span.set_tag("error", True)
ec = request.iscope.span.tags.get('ec', 0)
if ec is 0:
if ec == 0:
request.iscope.span.set_tag("ec", ec+1)

request.iscope.span.set_tag(ext.HTTP_STATUS_CODE, response.status_code)
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/flask/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def after_request_with_instana(response):
if 500 <= response.status_code <= 511:
span.set_tag("error", True)
ec = span.tags.get('ec', 0)
if ec is 0:
if ec == 0:
span.set_tag("ec", ec+1)

span.set_tag(ext.HTTP_STATUS_CODE, int(response.status_code))
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/flask/with_blinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def request_finished_with_instana(sender, response, **extra):
if 500 <= response.status_code <= 511:
span.set_tag("error", True)
ec = span.tags.get('ec', 0)
if ec is 0:
if ec == 0:
span.set_tag("ec", ec+1)

span.set_tag(ext.HTTP_STATUS_CODE, int(response.status_code))
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sqlalchemy import event
from sqlalchemy.engine import Engine

url_regexp = re.compile('\/\/(\S+@)')
url_regexp = re.compile(r"\/\/(\S+@)")

@event.listens_for(Engine, 'before_cursor_execute', named=True)
def receive_before_cursor_execute(**kw):
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/tornado/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def on_finish_with_instana(wrapped, instance, argv, kwargs):
if 500 <= status_code <= 511:
scope.span.set_tag("error", True)
ec = scope.span.tags.get('ec', 0)
if ec is 0:
if ec == 0:
scope.span.set_tag("ec", ec + 1)

scope.span.set_tag("http.status_code", status_code)
Expand Down
4 changes: 2 additions & 2 deletions instana/instrumentation/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def collect(instance, args, kwargs):
kvs['host'] = instance.host
kvs['port'] = instance.port

if args is not None and len(args) is 2:
if args is not None and len(args) == 2:
kvs['method'] = args[0]
kvs['path'] = args[1]
else:
Expand All @@ -31,7 +31,7 @@ def collect(instance, args, kwargs):
if kvs.get('path') is not None and ('?' in kvs['path']):
parts = kvs['path'].split('?')
kvs['path'] = parts[0]
if len(parts) is 2:
if len(parts) == 2:
kvs['query'] = strip_secrets(parts[1], agent.secrets_matcher, agent.secrets_list)

if type(instance) is urllib3.connectionpool.HTTPSConnectionPool:
Expand Down
6 changes: 3 additions & 3 deletions instana/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ def metric_work():
def process(self):
""" Collects, processes & reports metrics """
try:
if self.agent.machine.fsm.current is "wait4init":
if self.agent.machine.fsm.current == "wait4init":
# Test the host agent if we're ready to send data
if self.agent.is_agent_ready():
if self.agent.machine.fsm.current is not "good2go":
if self.agent.machine.fsm.current != "good2go":
self.agent.machine.fsm.ready()
else:
return
Expand All @@ -216,7 +216,7 @@ def process(self):
response = self.agent.report_data(ed)

if response:
if response.status_code is 200 and len(response.content) > 2:
if response.status_code == 200 and len(response.content) > 2:
# The host agent returned something indicating that is has a request for us that we
# need to process.
self.handle_agent_tasks(json.loads(response.content)[0])
Expand Down
2 changes: 1 addition & 1 deletion instana/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@ def __add_stack(self, span, limit=None):


# Used by __add_stack
re_tracer_frame = re.compile('/instana/.*\.py$')
re_tracer_frame = re.compile(r"/instana/.*\.py$")
re_with_stan_frame = re.compile('with_instana')
8 changes: 4 additions & 4 deletions instana/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .log import logger


if sys.version_info.major is 2:
if sys.version_info.major == 2:
string_types = basestring
else:
string_types = str
Expand Down Expand Up @@ -227,7 +227,7 @@ def sql_sanitizer(sql):


# Used by sql_sanitizer
regexp_sql_values = re.compile('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)')
regexp_sql_values = re.compile(r"('[\s\S][^']*'|\d*\.\d+|\d+|NULL)")


def get_default_gateway():
Expand All @@ -247,7 +247,7 @@ def get_default_gateway():
if '00000000' == parts[1]:
hip = parts[2]

if hip is not None and len(hip) is 8:
if hip is not None and len(hip) == 8:
# Reverse order, convert hex to int
return "%i.%i.%i.%i" % (int(hip[6:8], 16), int(hip[4:6], 16), int(hip[2:4], 16), int(hip[0:2], 16))

Expand Down Expand Up @@ -280,7 +280,7 @@ def get_py_source(file):


# Used by get_py_source
regexp_py = re.compile('\.py$')
regexp_py = re.compile(r"\.py$")


def every(delay, task, name):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_id_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import instana.util

if sys.version_info.major is 2:
if sys.version_info.major == 2:
string_types = basestring
else:
string_types = str
Expand Down
4 changes: 2 additions & 2 deletions tests/test_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_contains_no_match(self):

def test_regex(self):
matcher = 'regex'
kwlist = ['\d']
kwlist = [r"\d"]

query_params = "one=1&Two=two&THREE=&4='+'&five='okyeah'"

Expand All @@ -94,7 +94,7 @@ def test_regex(self):

def test_regex_no_match(self):
matcher = 'regex'
kwlist = ['\d\d\d']
kwlist = [r"\d\d\d"]

query_params = "one=1&Two=two&THREE=&4='+'&five='okyeah'"

Expand Down