Skip to content

Commit b70049d

Browse files
author
Ryo Kather
committed
resolve pylint and changed return type to str
resolve pylint Fixed linting and changed return type to str
1 parent f1fb942 commit b70049d

File tree

8 files changed

+14
-12
lines changed
  • instrumentation
    • opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client
    • opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi
    • opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests
    • opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado
    • opentelemetry-instrumentation-urllib
    • opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi
  • opentelemetry-instrumentation/src/opentelemetry/instrumentation

8 files changed

+14
-12
lines changed

instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ async def on_request_start(
172172
)
173173

174174
if trace_config_ctx.span.is_recording():
175-
url = remove_url_credentials(params.url)
176-
177175
attributes = {
178176
SpanAttributes.HTTP_METHOD: http_method,
179-
SpanAttributes.HTTP_URL: trace_config_ctx.url_filter(url)
177+
SpanAttributes.HTTP_URL: remove_url_credentials(
178+
trace_config_ctx.url_filter(params.url)
179+
)
180180
if callable(trace_config_ctx.url_filter)
181-
else str(url),
181+
else remove_url_credentials(str(params.url)),
182182
}
183183
for key, value in attributes.items():
184184
trace_config_ctx.span.set_attribute(key, value)

instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def collect_request_attributes(scope):
8989
SpanAttributes.NET_HOST_PORT: port,
9090
SpanAttributes.HTTP_FLAVOR: scope.get("http_version"),
9191
SpanAttributes.HTTP_TARGET: scope.get("path"),
92-
SpanAttributes.HTTP_URL: str(remove_url_credentials(http_url)),
92+
SpanAttributes.HTTP_URL: remove_url_credentials(http_url),
9393
}
9494
http_method = scope.get("method")
9595
if http_method:

instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _instrumented_requests_call(
127127
if not span_name or not isinstance(span_name, str):
128128
span_name = get_default_span_name(method)
129129

130-
url = str(remove_url_credentials(url))
130+
url = remove_url_credentials(url)
131131

132132
labels = {}
133133
labels[SpanAttributes.HTTP_METHOD] = method

instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def fetch_async(tracer, request_hook, response_hook, func, _, args, kwargs):
6464

6565
if span.is_recording():
6666
attributes = {
67-
SpanAttributes.HTTP_URL: str(remove_url_credentials(request.url)),
67+
SpanAttributes.HTTP_URL: remove_url_credentials(request.url),
6868
SpanAttributes.HTTP_METHOD: request.method,
6969
}
7070
for key, value in attributes.items():

instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _instrumented_open_call(
145145
if not span_name or not isinstance(span_name, str):
146146
span_name = get_default_span_name(method)
147147

148-
url = str(remove_url_credentials(url))
148+
url = remove_url_credentials(url)
149149

150150
labels = {
151151
SpanAttributes.HTTP_METHOD: method,

instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
from opentelemetry.trace import StatusCode
3737

3838
# pylint: disable=too-many-public-methods
39+
40+
3941
class RequestsIntegrationTestBase(abc.ABC):
4042
# pylint: disable=no-member
4143

instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def collect_request_attributes(environ):
131131
if target is not None:
132132
result[SpanAttributes.HTTP_TARGET] = target
133133
else:
134-
result[SpanAttributes.HTTP_URL] = str(
135-
remove_url_credentials(wsgiref_util.request_uri(environ))
134+
result[SpanAttributes.HTTP_URL] = remove_url_credentials(
135+
wsgiref_util.request_uri(environ)
136136
)
137137

138138
remote_addr = environ.get("REMOTE_ADDR")

opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def unwrap(obj, attr: str):
6363
setattr(obj, attr, func.__wrapped__)
6464

6565

66-
def remove_url_credentials(url: str) -> URL:
66+
def remove_url_credentials(url: str) -> str:
6767
"""Given a string url, attempt to remove the username and password"""
6868
try:
69-
url = URL(url).with_user(None)
69+
url = str(URL(url).with_user(None))
7070
except ValueError: # invalid url was passed
7171
pass
7272
return url

0 commit comments

Comments
 (0)