diff --git a/instana/instrumentation/asgi.py b/instana/instrumentation/asgi.py index 63cd04ad..93a8941e 100644 --- a/instana/instrumentation/asgi.py +++ b/instana/instrumentation/asgi.py @@ -26,6 +26,7 @@ def _extract_custom_headers(self, span, headers): def _collect_kvs(self, scope, span): try: + span.set_tag('span.kind', 'entry') span.set_tag('http.path', scope.get('path')) span.set_tag('http.method', scope.get('method')) diff --git a/instana/instrumentation/fastapi_inst.py b/instana/instrumentation/fastapi_inst.py index 92fa93b2..31d7d2c4 100644 --- a/instana/instrumentation/fastapi_inst.py +++ b/instana/instrumentation/fastapi_inst.py @@ -30,7 +30,7 @@ async def instana_exception_handler(request, exc): span = async_tracer.active_span if span is not None: - if hasattr(exc, 'detail'): + if hasattr(exc, 'detail') and (500 <= exc.status_code <= 599): span.set_tag('http.error', exc.detail) span.set_tag('http.status_code', exc.status_code) except Exception: diff --git a/instana/recorder.py b/instana/recorder.py index c2fbd666..866dc698 100644 --- a/instana/recorder.py +++ b/instana/recorder.py @@ -17,7 +17,7 @@ class StanRecorder(object): THREAD_NAME = "Instana Span Reporting" - REGISTERED_SPANS = ("aiohttp-client", "aiohttp-server", "asgi", "aws.lambda.entry", "boto3", "cassandra", + REGISTERED_SPANS = ("aiohttp-client", "aiohttp-server", "aws.lambda.entry", "boto3", "cassandra", "celery-client", "celery-worker", "couchbase", "django", "gcs", "log", "memcache", "mongo", "mysql", "postgres", "pymongo", "rabbitmq", "redis", "render", "rpc-client", "rpc-server", "sqlalchemy", "soap", "tornado-client", diff --git a/instana/span.py b/instana/span.py index 2baa94c0..8c7f78e4 100644 --- a/instana/span.py +++ b/instana/span.py @@ -120,7 +120,7 @@ def _validate_tags(self, tags): :param tags: dict of tags :return: dict - a filtered set of tags """ - filtered_tags = {} + filtered_tags = DictionaryOfStan() for key in tags.keys(): validated_key, validated_value = self._validate_tag(key, tags[key]) if validated_key is not None and validated_value is not None: @@ -227,14 +227,14 @@ def get_span_kind(self, span): class RegisteredSpan(BaseSpan): - HTTP_SPANS = ("aiohttp-client", "aiohttp-server", "asgi", "django", "http", "soap", "tornado-client", + HTTP_SPANS = ("aiohttp-client", "aiohttp-server", "django", "http", "soap", "tornado-client", "tornado-server", "urllib3", "wsgi") 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") - ENTRY_SPANS = ("aiohttp-server", "asgi", "aws.lambda.entry", "celery-worker", "django", "wsgi", "rabbitmq", + ENTRY_SPANS = ("aiohttp-server", "aws.lambda.entry", "celery-worker", "django", "wsgi", "rabbitmq", "rpc-server", "tornado-server") LOCAL_SPANS = ("render") diff --git a/setup.py b/setup.py index f2530a86..03b39fd7 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ def check_setuptools(): 'opentracing>=2.3.0', 'requests>=2.8.0', 'six>=1.12.0', - 'urllib3>=1.18.1'], + 'urllib3<1.26,>=1.21.1'], entry_points={ 'instana': ['string = instana:load'], 'flask': ['string = instana:load'], # deprecated: use same as 'instana' @@ -79,14 +79,14 @@ def check_setuptools(): 'nose>=1.0', 'pyramid>=1.2', 'pytest>=4.6', - 'urllib3[secure]>=1.15,<=1.25.11' + 'urllib3[secure]!=1.25.0,!=1.25.1,<1.26,>=1.21.1' ], 'test-cassandra': [ 'cassandra-driver==3.20.2', 'mock>=2.0.0', 'nose>=1.0', 'pytest>=4.6', - 'urllib3[secure]>=1.15<=1.25.11' + 'urllib3[secure]!=1.25.0,!=1.25.1,<1.26,>=1.21.1' ], 'test-couchbase': [ 'couchbase==2.5.9', @@ -122,7 +122,7 @@ def check_setuptools(): 'suds-jurko>=0.6', 'tornado>=4.5.3,<6.0', 'uvicorn>=0.12.2;python_version>="3.6"', - 'urllib3[secure]>=1.15,<=1.25.11' + 'urllib3[secure]!=1.25.0,!=1.25.1,<1.26,>=1.21.1' ], }, test_suite='nose.collector', diff --git a/tests/frameworks/test_fastapi.py b/tests/frameworks/test_fastapi.py index 8d4163d7..3f3e5e04 100644 --- a/tests/frameworks/test_fastapi.py +++ b/tests/frameworks/test_fastapi.py @@ -20,7 +20,7 @@ def server(): def test_vanilla_get(server): result = requests.get(testenv["fastapi_server"] + '/') - assert result.status_code is 200 + assert result.status_code == 200 assert "X-Instana-T" in result.headers assert "X-Instana-S" in result.headers assert "X-Instana-L" in result.headers @@ -30,7 +30,7 @@ def test_vanilla_get(server): spans = tracer.recorder.queued_spans() # FastAPI instrumentation (like all instrumentation) _always_ traces unless told otherwise assert len(spans) == 1 - assert spans[0].n == 'asgi' + assert spans[0].n == 'sdk' def test_basic_get(server): @@ -43,7 +43,7 @@ def test_basic_get(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -51,7 +51,7 @@ def test_basic_get(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -68,15 +68,14 @@ def test_basic_get(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) def test_400(server): result = None @@ -88,7 +87,7 @@ def test_400(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -96,7 +95,7 @@ def test_400(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -113,15 +112,14 @@ def test_400(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/400') - assert(asgi_span.data['http']['path_tpl'] == '/400') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 400) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/400') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/400') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 400) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) def test_500(server): result = None @@ -133,7 +131,7 @@ def test_500(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -141,7 +139,7 @@ def test_500(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -158,16 +156,14 @@ def test_500(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == 1) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/500') - assert(asgi_span.data['http']['path_tpl'] == '/500') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 500) - assert(asgi_span.data['http']['error'] == None) - + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/500') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/500') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 500) + assert(asgi_span.data['sdk']['custom']['tags']['http.error'] == '500 response') + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) def test_path_templates(server): result = None @@ -179,7 +175,7 @@ def test_path_templates(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -187,7 +183,7 @@ def test_path_templates(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -204,16 +200,14 @@ def test_path_templates(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/users/1') - assert(asgi_span.data['http']['path_tpl'] == '/users/{user_id}') - assert(asgi_span.data['http']['params'] == None) - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/users/1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/users/{user_id}') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) def test_secret_scrubbing(server): result = None @@ -225,7 +219,7 @@ def test_secret_scrubbing(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -233,7 +227,7 @@ def test_secret_scrubbing(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -250,16 +244,15 @@ def test_secret_scrubbing(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['params'] == 'secret=') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.params'] == 'secret=') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + def test_synthetic_request(server): request_headers = { @@ -273,7 +266,7 @@ def test_synthetic_request(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -281,7 +274,7 @@ def test_synthetic_request(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -298,16 +291,15 @@ def test_synthetic_request(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) - + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) + assert(asgi_span.sy) assert(urllib3_span.sy is None) assert(test_span.sy is None) @@ -329,7 +321,7 @@ def test_custom_header_capture(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -337,7 +329,7 @@ def test_custom_header_capture(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -354,17 +346,16 @@ def test_custom_header_capture(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) - - assert("http.X-Capture-This" in asgi_span.data["custom"]['tags']) - assert("this" == asgi_span.data["custom"]['tags']["http.X-Capture-This"]) - assert("http.X-Capture-That" in asgi_span.data["custom"]['tags']) - assert("that" == asgi_span.data["custom"]['tags']["http.X-Capture-That"]) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) + + assert("http.X-Capture-This" in asgi_span.data["sdk"]["custom"]['tags']) + assert("this" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-This"]) + assert("http.X-Capture-That" in asgi_span.data["sdk"]["custom"]['tags']) + assert("that" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-That"]) diff --git a/tests/frameworks/test_starlette.py b/tests/frameworks/test_starlette.py index 991de2a7..b2a90308 100644 --- a/tests/frameworks/test_starlette.py +++ b/tests/frameworks/test_starlette.py @@ -23,7 +23,7 @@ def test_vanilla_get(server): spans = tracer.recorder.queued_spans() # Starlette instrumentation (like all instrumentation) _always_ traces unless told otherwise assert len(spans) == 1 - assert spans[0].n == 'asgi' + assert spans[0].n == 'sdk' assert "X-Instana-T" in result.headers assert "X-Instana-S" in result.headers @@ -41,7 +41,7 @@ def test_basic_get(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -49,7 +49,7 @@ def test_basic_get(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -66,15 +66,14 @@ def test_basic_get(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) def test_path_templates(server): result = None @@ -86,7 +85,7 @@ def test_path_templates(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -94,7 +93,7 @@ def test_path_templates(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -111,16 +110,14 @@ def test_path_templates(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/users/1') - assert(asgi_span.data['http']['path_tpl'] == '/users/{user_id}') - assert(asgi_span.data['http']['params'] == None) - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/users/1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/users/{user_id}') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) def test_secret_scrubbing(server): result = None @@ -132,7 +129,7 @@ def test_secret_scrubbing(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -140,7 +137,7 @@ def test_secret_scrubbing(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -157,16 +154,14 @@ def test_secret_scrubbing(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['params'] == 'secret=') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.params'] == 'secret=') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) def test_synthetic_request(server): request_headers = { @@ -180,7 +175,7 @@ def test_synthetic_request(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -188,7 +183,7 @@ def test_synthetic_request(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -205,15 +200,14 @@ def test_synthetic_request(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) assert(asgi_span.sy) assert(urllib3_span.sy is None) @@ -236,7 +230,7 @@ def test_custom_header_capture(server): spans = tracer.recorder.queued_spans() assert len(spans) == 3 - span_filter = lambda span: span.n == "sdk" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'test' test_span = get_first_span_by_filter(spans, span_filter) assert(test_span) @@ -244,7 +238,7 @@ def test_custom_header_capture(server): urllib3_span = get_first_span_by_filter(spans, span_filter) assert(urllib3_span) - span_filter = lambda span: span.n == "asgi" + span_filter = lambda span: span.n == "sdk" and span.data['sdk']['name'] == 'asgi' asgi_span = get_first_span_by_filter(spans, span_filter) assert(asgi_span) @@ -261,17 +255,16 @@ def test_custom_header_capture(server): assert "Server-Timing" in result.headers assert result.headers["Server-Timing"] == ("intid;desc=%s" % asgi_span.t) - assert('http' in asgi_span.data) assert(asgi_span.ec == None) - assert(isinstance(asgi_span.stack, list)) - assert(asgi_span.data['http']['host'] == '127.0.0.1') - assert(asgi_span.data['http']['path'] == '/') - assert(asgi_span.data['http']['path_tpl'] == '/') - assert(asgi_span.data['http']['method'] == 'GET') - assert(asgi_span.data['http']['status'] == 200) - assert(asgi_span.data['http']['error'] == None) - - assert("http.X-Capture-This" in asgi_span.data["custom"]['tags']) - assert("this" == asgi_span.data["custom"]['tags']["http.X-Capture-This"]) - assert("http.X-Capture-That" in asgi_span.data["custom"]['tags']) - assert("that" == asgi_span.data["custom"]['tags']["http.X-Capture-That"]) + assert(asgi_span.data['sdk']['custom']['tags']['http.host'] == '127.0.0.1') + assert(asgi_span.data['sdk']['custom']['tags']['http.path'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.path_tpl'] == '/') + assert(asgi_span.data['sdk']['custom']['tags']['http.method'] == 'GET') + assert(asgi_span.data['sdk']['custom']['tags']['http.status_code'] == 200) + assert('http.error' not in asgi_span.data['sdk']['custom']['tags']) + assert('http.params' not in asgi_span.data['sdk']['custom']['tags']) + + assert("http.X-Capture-This" in asgi_span.data["sdk"]["custom"]['tags']) + assert("this" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-This"]) + assert("http.X-Capture-That" in asgi_span.data["sdk"]["custom"]['tags']) + assert("that" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-That"])