Skip to content

Commit 2c960c8

Browse files
author
Peter Giacomo Lombardo
authored
ASGI: Update span type (#287)
* ASGI: Report as alt SDK span * Update tests to follow span type change * Better version limiting around urllib3 bug * Error log on 5xx only * 20 years of development experience; still fixing typos * Make urllib3 version limit package wide * Update Starlette tests to follow span changes
1 parent 2609f53 commit 2c960c8

File tree

7 files changed

+133
-148
lines changed

7 files changed

+133
-148
lines changed

instana/instrumentation/asgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def _extract_custom_headers(self, span, headers):
2626

2727
def _collect_kvs(self, scope, span):
2828
try:
29+
span.set_tag('span.kind', 'entry')
2930
span.set_tag('http.path', scope.get('path'))
3031
span.set_tag('http.method', scope.get('method'))
3132

instana/instrumentation/fastapi_inst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def instana_exception_handler(request, exc):
3030
span = async_tracer.active_span
3131

3232
if span is not None:
33-
if hasattr(exc, 'detail'):
33+
if hasattr(exc, 'detail') and (500 <= exc.status_code <= 599):
3434
span.set_tag('http.error', exc.detail)
3535
span.set_tag('http.status_code', exc.status_code)
3636
except Exception:

instana/recorder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class StanRecorder(object):
1818
THREAD_NAME = "Instana Span Reporting"
1919

20-
REGISTERED_SPANS = ("aiohttp-client", "aiohttp-server", "asgi", "aws.lambda.entry", "boto3", "cassandra",
20+
REGISTERED_SPANS = ("aiohttp-client", "aiohttp-server", "aws.lambda.entry", "boto3", "cassandra",
2121
"celery-client", "celery-worker", "couchbase", "django", "gcs", "log",
2222
"memcache", "mongo", "mysql", "postgres", "pymongo", "rabbitmq", "redis",
2323
"render", "rpc-client", "rpc-server", "sqlalchemy", "soap", "tornado-client",

instana/span.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _validate_tags(self, tags):
120120
:param tags: dict of tags
121121
:return: dict - a filtered set of tags
122122
"""
123-
filtered_tags = {}
123+
filtered_tags = DictionaryOfStan()
124124
for key in tags.keys():
125125
validated_key, validated_value = self._validate_tag(key, tags[key])
126126
if validated_key is not None and validated_value is not None:
@@ -227,14 +227,14 @@ def get_span_kind(self, span):
227227

228228

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

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

237-
ENTRY_SPANS = ("aiohttp-server", "asgi", "aws.lambda.entry", "celery-worker", "django", "wsgi", "rabbitmq",
237+
ENTRY_SPANS = ("aiohttp-server", "aws.lambda.entry", "celery-worker", "django", "wsgi", "rabbitmq",
238238
"rpc-server", "tornado-server")
239239

240240
LOCAL_SPANS = ("render")

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def check_setuptools():
6363
'opentracing>=2.3.0',
6464
'requests>=2.8.0',
6565
'six>=1.12.0',
66-
'urllib3>=1.18.1'],
66+
'urllib3<1.26,>=1.21.1'],
6767
entry_points={
6868
'instana': ['string = instana:load'],
6969
'flask': ['string = instana:load'], # deprecated: use same as 'instana'
@@ -79,14 +79,14 @@ def check_setuptools():
7979
'nose>=1.0',
8080
'pyramid>=1.2',
8181
'pytest>=4.6',
82-
'urllib3[secure]>=1.15,<=1.25.11'
82+
'urllib3[secure]!=1.25.0,!=1.25.1,<1.26,>=1.21.1'
8383
],
8484
'test-cassandra': [
8585
'cassandra-driver==3.20.2',
8686
'mock>=2.0.0',
8787
'nose>=1.0',
8888
'pytest>=4.6',
89-
'urllib3[secure]>=1.15<=1.25.11'
89+
'urllib3[secure]!=1.25.0,!=1.25.1,<1.26,>=1.21.1'
9090
],
9191
'test-couchbase': [
9292
'couchbase==2.5.9',
@@ -122,7 +122,7 @@ def check_setuptools():
122122
'suds-jurko>=0.6',
123123
'tornado>=4.5.3,<6.0',
124124
'uvicorn>=0.12.2;python_version>="3.6"',
125-
'urllib3[secure]>=1.15,<=1.25.11'
125+
'urllib3[secure]!=1.25.0,!=1.25.1,<1.26,>=1.21.1'
126126
],
127127
},
128128
test_suite='nose.collector',

0 commit comments

Comments
 (0)