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
2 changes: 0 additions & 2 deletions example/asyncio/aioclient.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2019

from __future__ import absolute_import

import aiohttp
import asyncio

Expand Down
9 changes: 0 additions & 9 deletions example/autoprofile/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import time
import threading
import random
import traceback
import sys
import os

Expand All @@ -13,14 +12,6 @@
os.environ['INSTANA_AUTOPROFILE'] = 'yes'
import instana

try:
# python 2
from urllib2 import urlopen
except ImportError:
# python 3
from urllib.request import urlopen


# Simulate CPU intensive work
def simulate_cpu():
for i in range(5000000):
Expand Down
5 changes: 1 addition & 4 deletions instana/collector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
from ..util import every, DictionaryOfStan


if sys.version_info.major == 2:
import Queue as queue
else:
import queue # pylint: disable=import-error
import queue # pylint: disable=import-error


class BaseCollector(object):
Expand Down
7 changes: 2 additions & 5 deletions instana/instrumentation/celery/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import opentracing

from ...log import logger
from ...singletons import tracer
from ...util.traceutils import get_active_tracer
Expand All @@ -12,11 +13,7 @@
from celery import registry, signals
from .catalog import task_catalog_get, task_catalog_pop, task_catalog_push, get_task_id

try:
from urllib import parse
except ImportError:
import urlparse as parse
import urllib
from urllib import parse


def add_broker_tags(span, broker_url):
Expand Down
6 changes: 1 addition & 5 deletions instana/instrumentation/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ def process_exception(self, request, exception):

def __url_pattern_route(self, view_name):
from django.conf import settings
try:
from django.urls import RegexURLPattern as URLPattern
from django.urls import RegexURLResolver as URLResolver
except ImportError:
from django.urls import URLPattern, URLResolver
from django.urls import RegexURLResolver as URLResolver

urlconf = __import__(settings.ROOT_URLCONF, {}, {}, [''])

Expand Down
8 changes: 1 addition & 7 deletions instana/instrumentation/google/cloud/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
# (c) Copyright Instana Inc. 2020

import re

try:
# Python 3
from urllib.parse import unquote
except ImportError:
# Python 2
from urllib import unquote
from urllib.parse import unquote

# _storage_api defines a conversion of Google Storage JSON API requests into span tags as follows:
# request_method -> path_matcher -> collector
Expand Down
11 changes: 4 additions & 7 deletions instana/propagators/base_propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@


import sys
import os

from instana.log import logger
from instana.util.ids import header_to_id, header_to_long_id
from instana.span_context import SpanContext
from instana.w3c_trace_context.traceparent import Traceparent
from instana.w3c_trace_context.tracestate import Tracestate
import os

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3


# The carrier can be a dict or a list.
Expand Down Expand Up @@ -233,7 +230,7 @@ def __extract_instana_headers(self, dc):

level = dc.get(self.LC_HEADER_KEY_L) or dc.get(self.ALT_LC_HEADER_KEY_L) or dc.get(
self.B_HEADER_KEY_L) or dc.get(self.B_ALT_LC_HEADER_KEY_L)
if level and PY3 is True and isinstance(level, bytes):
if level and isinstance(level, bytes):
level = level.decode("utf-8")

synthetic = dc.get(self.LC_HEADER_KEY_SYNTHETIC) or dc.get(self.ALT_LC_HEADER_KEY_SYNTHETIC) or dc.get(
Expand All @@ -258,12 +255,12 @@ def __extract_w3c_trace_context_headers(self, dc):
try:
traceparent = dc.get(self.HEADER_KEY_TRACEPARENT) or dc.get(self.ALT_HEADER_KEY_TRACEPARENT) or dc.get(
self.B_HEADER_KEY_TRACEPARENT) or dc.get(self.B_ALT_HEADER_KEY_TRACEPARENT)
if traceparent and PY3 is True and isinstance(traceparent, bytes):
if traceparent and isinstance(traceparent, bytes):
traceparent = traceparent.decode("utf-8")

tracestate = dc.get(self.HEADER_KEY_TRACESTATE) or dc.get(self.ALT_HEADER_KEY_TRACESTATE) or dc.get(
self.B_HEADER_KEY_TRACESTATE) or dc.get(self.B_ALT_HEADER_KEY_TRACESTATE)
if tracestate and PY3 is True and isinstance(tracestate, bytes):
if tracestate and isinstance(tracestate, bytes):
tracestate = tracestate.decode("utf-8")

except Exception:
Expand Down
4 changes: 2 additions & 2 deletions instana/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class StanRecorder(object):
"couchbase", "django", "gcs", "gcps-producer",
"gcps-consumer", "log", "memcache", "mongo", "mysql",
"postgres", "pymongo", "rabbitmq", "redis","render",
"rpc-client", "rpc-server", "sqlalchemy", "soap",
"tornado-client", "tornado-server", "urllib3", "wsgi", "asgi")
"rpc-client", "rpc-server", "sqlalchemy", "tornado-client",
"tornado-server", "urllib3", "wsgi", "asgi")

# Recorder thread for collection/reporting of spans
thread = None
Expand Down
7 changes: 2 additions & 5 deletions instana/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ def get_span_kind(self, span):


class RegisteredSpan(BaseSpan):
HTTP_SPANS = ("aiohttp-client", "aiohttp-server", "django", "http", "soap", "tornado-client",
HTTP_SPANS = ("aiohttp-client", "aiohttp-server", "django", "http", "tornado-client",
"tornado-server", "urllib3", "wsgi", "asgi")

EXIT_SPANS = ("aiohttp-client", "boto3", "cassandra", "celery-client", "couchbase", "log", "memcache",
"mongo", "mysql", "postgres", "rabbitmq", "redis", "rpc-client", "sqlalchemy",
"soap", "tornado-client", "urllib3", "pymongo", "gcs", "gcps-producer")
"tornado-client", "urllib3", "pymongo", "gcs", "gcps-producer")

ENTRY_SPANS = ("aiohttp-server", "aws.lambda.entry", "celery-worker", "django", "wsgi", "rabbitmq",
"rpc-server", "tornado-server", "gcps-consumer", "asgi")
Expand Down Expand Up @@ -501,9 +501,6 @@ def _collect_http_tags(self, span):
self.data["http"]["error"] = span.tags.pop('http.error', None)

if len(span.tags) > 0:
if span.operation_name == "soap":
self.data["soap"]["action"] = span.tags.pop('soap.action', None)

custom_headers = []
for key in span.tags:
if key[0:12] == "http.header.":
Expand Down
18 changes: 2 additions & 16 deletions instana/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,14 @@
# (c) Copyright Instana Inc. 2020

import json
import sys
import time

from collections import defaultdict
import pkg_resources
from urllib import parse

try:
from urllib import parse
except ImportError:
import urlparse as parse
import urllib
import pkg_resources

from ..log import logger

if sys.version_info.major == 2:
string_types = basestring
else:
string_types = str

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3

def nested_dictionary():
return defaultdict(DictionaryOfStan)

Expand Down
17 changes: 4 additions & 13 deletions instana/util/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# (c) Copyright Instana Inc. 2020

import os
import sys
import time
import random

Expand All @@ -11,14 +10,6 @@

BAD_ID = "BADCAFFE" # Bad Caffe

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3

if PY2:
string_types = basestring
else:
string_types = str


def generate_id():
""" Generate a 64bit base 16 ID for use as a Span or Trace ID """
Expand All @@ -45,10 +36,10 @@ def header_to_long_id(header):
:param header: the header to analyze, validate and convert (if needed)
:return: a valid ID to be used internal to the tracer
"""
if PY3 is True and isinstance(header, bytes):
if isinstance(header, bytes):
header = header.decode('utf-8')

if not isinstance(header, string_types):
if not isinstance(header, str):
return BAD_ID

try:
Expand All @@ -74,10 +65,10 @@ def header_to_id(header):
:param header: the header to analyze, validate and convert (if needed)
:return: a valid ID to be used internal to the tracer
"""
if PY3 is True and isinstance(header, bytes):
if isinstance(header, bytes):
header = header.decode('utf-8')

if not isinstance(header, string_types):
if not isinstance(header, str):
return BAD_ID

try:
Expand Down
15 changes: 2 additions & 13 deletions instana/util/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
# (c) Copyright Instana Inc. 2020

import re
import re
import sys

try:
from urllib import parse
except ImportError:
import urlparse as parse
import urllib
from urllib import parse

from ..util import PY2, PY3
from ..log import logger


Expand Down Expand Up @@ -127,10 +119,7 @@ def strip_secrets_from_query(qp, matcher, kwlist):
logger.debug("strip_secrets_from_query: unknown matcher")
return qp

if PY2:
result = urllib.urlencode(params, doseq=True)
else:
result = parse.urlencode(params, doseq=True)
result = parse.urlencode(params, doseq=True)
query = parse.unquote(result)

if path:
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2017

from __future__ import absolute_import
import os

os.environ["INSTANA_TEST"] = "true"
Expand Down
2 changes: 0 additions & 2 deletions tests/apps/grpc_server/stan_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2019

from __future__ import absolute_import

import time
import random

Expand Down
12 changes: 0 additions & 12 deletions tests/apps/soap_app/__init__.py

This file was deleted.

67 changes: 0 additions & 67 deletions tests/apps/soap_app/app.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/clients/boto3/test_boto3_lambda.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2020

from __future__ import absolute_import
import unittest
import json

Expand Down
1 change: 0 additions & 1 deletion tests/clients/boto3/test_boto3_s3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2020

from __future__ import absolute_import
import os
import unittest

Expand Down
Loading