Skip to content

Commit fc21cd3

Browse files
committed
ci(tornado): run on the latest version
Signed-off-by: Varsha GS <varsha.gs@ibm.com>
1 parent 1076b78 commit fc21cd3

8 files changed

Lines changed: 24 additions & 34 deletions

File tree

src/instana/instrumentation/tornado/client.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# (c) Copyright IBM Corp. 2021
22
# (c) Copyright Instana Inc. 2019
33

4+
try:
5+
import tornado
46

5-
import wrapt
6-
import functools
7+
import wrapt
8+
import functools
79

8-
from instana.log import logger
9-
from instana.singletons import agent, tracer
10-
from instana.util.secrets import strip_secrets_from_query
11-
from instana.propagators.format import Format
12-
from instana.span.span import get_current_span
10+
from opentelemetry.semconv.trace import SpanAttributes
1311

14-
try:
15-
import tornado
12+
from instana.log import logger
13+
from instana.singletons import agent, tracer
14+
from instana.util.secrets import strip_secrets_from_query
15+
from instana.propagators.format import Format
16+
from instana.span.span import get_current_span
1617

1718
@wrapt.patch_function_wrapper('tornado.httpclient', 'AsyncHTTPClient.fetch')
1819
def fetch_with_instana(wrapped, instance, argv, kwargs):
@@ -49,8 +50,8 @@ def fetch_with_instana(wrapped, instance, argv, kwargs):
4950
agent.options.secrets_list)
5051
span.set_attribute("http.params", cleaned_qp)
5152

52-
span.set_attribute("http.url", parts[0])
53-
span.set_attribute("http.method", request.method)
53+
span.set_attribute(SpanAttributes.HTTP_URL, parts[0])
54+
span.set_attribute(SpanAttributes.HTTP_METHOD, request.method)
5455

5556
future = wrapped(request, **kwargs)
5657

@@ -66,9 +67,9 @@ def fetch_with_instana(wrapped, instance, argv, kwargs):
6667
def finish_tracing(future, span):
6768
try:
6869
response = future.result()
69-
span.set_attribute("http.status_code", response.code)
70+
span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, response.code)
7071
except tornado.httpclient.HTTPClientError as e:
71-
span.set_attribute("http.status_code", e.code)
72+
span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, e.code)
7273
span.record_exception(e)
7374
logger.debug("Tornado finish_tracing HTTPClientError: ", exc_info=True)
7475
finally:

src/instana/instrumentation/tornado/server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import wrapt
99

10+
from opentelemetry.semconv.trace import SpanAttributes
11+
1012
from instana.log import logger
1113
from instana.singletons import agent, tracer
1214
from instana.util.secrets import strip_secrets_from_query
@@ -41,8 +43,8 @@ def execute_with_instana(wrapped, instance, argv, kwargs):
4143
span.set_attribute("http.params", cleaned_qp)
4244

4345
url = f"{instance.request.protocol}://{instance.request.host}{instance.request.path}"
44-
span.set_attribute("http.url", url)
45-
span.set_attribute("http.method", instance.request.method)
46+
span.set_attribute(SpanAttributes.HTTP_URL, url)
47+
span.set_attribute(SpanAttributes.HTTP_METHOD, instance.request.method)
4648

4749
span.set_attribute("handler", instance.__class__.__name__)
4850

@@ -87,7 +89,7 @@ def on_finish_with_instana(wrapped, instance, argv, kwargs):
8789
if 500 <= status_code:
8890
span.mark_as_errored()
8991

90-
span.set_attribute("http.status_code", status_code)
92+
span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code)
9193
if span.is_recording():
9294
span.end()
9395

tests/conftest.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
collect_ignore_glob.append("*frameworks/test_celery*")
3535
collect_ignore_glob.append("*frameworks/test_gevent*")
3636
collect_ignore_glob.append("*frameworks/test_grpcio*")
37-
collect_ignore_glob.append("*frameworks/test_tornado*")
3837

3938
# # Cassandra and gevent tests are run in dedicated jobs on CircleCI and will
4039
# # be run explicitly. (So always exclude them here)
@@ -48,14 +47,6 @@
4847
# collect_ignore_glob.append("*test_gevent*")
4948
# collect_ignore_glob.append("*test_starlette*")
5049

51-
# Python 3.10 support is incomplete yet
52-
# TODO: Remove this once we start supporting Tornado >= 6.0
53-
if sys.version_info >= (3, 10):
54-
collect_ignore_glob.append("*test_tornado*")
55-
# Furthermore on Python 3.11 the above TC is skipped:
56-
# tests/opentracing/test_ot_span.py::TestOTSpan::test_stacks
57-
# TODO: Remove that once we find a workaround or DROP opentracing!
58-
5950
if sys.version_info >= (3, 11):
6051
if not os.environ.get("GOOGLE_CLOUD_TEST"):
6152
collect_ignore_glob.append("*test_google-cloud*")
@@ -64,6 +55,7 @@
6455
# TODO: Test Case failures for unknown reason:
6556
collect_ignore_glob.append("*test_aiohttp_server*")
6657
collect_ignore_glob.append("*test_celery*")
58+
collect_ignore_glob.append("*frameworks/test_tornado_server*")
6759

6860
# Currently there is a runtime incompatibility caused by the library:
6961
# `undefined symbol: _PyErr_WriteUnraisableMsg`

tests/requirements-310-with-tornado.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/requirements-310.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ responses<=0.17.0
3838
sanic>=19.9.0
3939
sanic-testing>=24.6.0
4040
sqlalchemy>=2.0.0
41+
tornado>=6.4.1
4142

4243
uvicorn>=0.13.4
4344
urllib3>=1.26.5

tests/requirements-312.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ responses<=0.17.0
3636
sanic>=19.9.0
3737
sanic-testing>=24.6.0
3838
sqlalchemy>=2.0.0
39+
tornado>=6.4.1
3940

4041
uvicorn>=0.13.4
4142
urllib3>=1.26.5

tests/requirements-313.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ responses<=0.17.0
4848
#sanic>=19.9.0
4949
#sanic-testing>=24.6.0
5050
sqlalchemy>=2.0.0
51+
tornado>=6.4.1
5152

5253
uvicorn>=0.13.4
5354
urllib3>=1.26.5

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ responses<=0.17.0
3737
sanic>=19.9.0
3838
sanic-testing>=24.6.0
3939
sqlalchemy>=2.0.0
40-
tornado>=4.5.3,<6.0
40+
tornado>=6.4.1
4141
uvicorn>=0.13.4
4242
urllib3>=1.26.5
4343
httpx>=0.27.0

0 commit comments

Comments
 (0)