Skip to content
This repository was archived by the owner on Sep 4, 2022. It is now read-only.

Commit 1650be6

Browse files
committed
fix(aiohttp): fixed Nimrod's CR
1 parent 0cc1c49 commit 1650be6

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

cisco_telescope/instrumentations/aiohttp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def _decode_chunk(chunk):
192192
decoded_chunk = chunk.decode()
193193
except UnicodeDecodeError as e:
194194
decoded_chunk = str(chunk)
195-
logging.info(f"Could'nt decode the chunk: {decoded_chunk}, {e}")
195+
logging.info(f"Could not decode body chunk: {decoded_chunk}, {e}")
196196

197197
return decoded_chunk
198198

tests/instrumentations/test_aiohttp.py

+22-20
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,28 @@ async def test_post_request_sanity(self):
7171

7272
async def test_post_request_invalid_utf8(self):
7373
Configuration().payloads_enabled = True
74-
data_to_send = b'/">Miso\xdfNoContinuation'
75-
async with aiohttp.client.request(
76-
method="POST",
77-
url=self.http_url_sanity,
78-
headers=self.request_headers(),
79-
chunked=True,
80-
data=data_to_send,
81-
) as resp:
82-
self._assert_basic_attributes_and_headers(resp)
83-
spans = self.memory_exporter.get_finished_spans()
84-
span = spans[0]
85-
86-
self.assertEqual(
87-
span.attributes[SemanticAttributes.HTTP_REQUEST_BODY],
88-
str(data_to_send),
89-
)
90-
self.assertEqual(
91-
span.attributes[SemanticAttributes.HTTP_RESPONSE_BODY],
92-
self.response_body(),
93-
)
74+
with self.assertLogs() as logs_written:
75+
data_to_send = b'/">Miso\xdfNoContinuation'
76+
async with aiohttp.client.request(
77+
method="POST",
78+
url=self.http_url_sanity,
79+
headers=self.request_headers(),
80+
chunked=True,
81+
data=data_to_send,
82+
) as resp:
83+
self._assert_basic_attributes_and_headers(resp)
84+
spans = self.memory_exporter.get_finished_spans()
85+
span = spans[0]
86+
87+
self.assertEqual(
88+
span.attributes[SemanticAttributes.HTTP_REQUEST_BODY],
89+
str(data_to_send),
90+
)
91+
self.assertEqual(
92+
span.attributes[SemanticAttributes.HTTP_RESPONSE_BODY],
93+
self.response_body(),
94+
)
95+
self.assertEqual(len(logs_written.records), 1)
9496

9597
async def test_get_request_error(self):
9698
Configuration().payloads_enabled = True

0 commit comments

Comments
 (0)