Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pubnub/request_handlers/async_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ async def async_request(self, options_func, cancellation_event):
uuid=uuid,
auth_key=auth_key,
client_request=None,
client_response=response
client_response=response,
http_version=f"HTTP/{response.version.major}.{response.version.minor}" if response.version else None
Comment thread
parfeon marked this conversation as resolved.
)

# if body is not None and len(body) > 0 and not options.non_json_response:
Expand Down Expand Up @@ -173,6 +174,10 @@ async def async_request(self, options_func, cancellation_event):
data = "N/A"

logger.debug(data)
logger.debug(
"PubNub request completed: operation=%s protocol=%s"
% (options.operation_type, response_info.http_version)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug probably over informative, but we don't have other levels yet.
I would suggest to merge it with data log above.


if response.status not in (200, 307, 204):

Expand Down
7 changes: 6 additions & 1 deletion pubnub/request_handlers/async_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ async def async_request(self, options_func, cancellation_event):
uuid=uuid,
auth_key=auth_key,
client_request=None,
client_response=response
client_response=response,
http_version=response.http_version
)

# if body is not None and len(body) > 0 and not options.non_json_response:
Expand Down Expand Up @@ -225,6 +226,10 @@ async def async_request(self, options_func, cancellation_event):
data = "N/A"

logger.debug(data)
logger.debug(
"PubNub request completed: operation=%s protocol=%s"
% (options.operation_type, response_info.http_version)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug probably over informative, but we don't have other levels yet.
I would suggest to merge it with data log above.


if response.status_code not in (200, 307, 204):

Expand Down
8 changes: 7 additions & 1 deletion pubnub/request_handlers/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def _build_envelope(self, p_options, e_options):
origin=res.url.host,
uuid=uuid,
auth_key=auth_key,
client_request=res.request
client_request=res.request,
http_version=res.http_version
)

if res.status_code not in [200, 204, 307]:
Expand Down Expand Up @@ -433,6 +434,11 @@ def _invoke_request(self, p_options, e_options, base_origin):

try:
res = session.request(**args)
logger.debug(
"PubNub request completed: operation=%s protocol=%s"
% (e_options.operation_type, res.http_version)
)

# Safely access response text - read content first for streaming responses
try:
logger.debug("GOT %s" % res.text)
Expand Down
16 changes: 15 additions & 1 deletion pubnub/request_handlers/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ def _build_envelope(self, p_options, e_options):
origin=url.hostname,
uuid=uuid,
auth_key=auth_key,
client_request=res.request
client_request=res.request,
http_version=(
Comment thread
parfeon marked this conversation as resolved.
f"HTTP/{res.raw.version // 10}.{res.raw.version % 10}"
if res.raw and res.raw.version else None
)
)

if not res.ok:
Expand Down Expand Up @@ -269,6 +273,16 @@ def _invoke_request(self, p_options, e_options, base_origin):
try:
res = self.session.request(**args)
logger.debug("GOT %s" % res.text)

http_ver = (
f"HTTP/{res.raw.version // 10}.{res.raw.version % 10}"
if res.raw and res.raw.version else "unknown"
)
logger.debug(
"PubNub request completed: operation=%s protocol=%s"
% (e_options.operation_type, http_ver)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we actually print it if version information available in response?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what I've been told to deliver:

Deliverables:

Debug logs such as:

PubNub request completed: operation=subscribe protocol=HTTP/2
PubNub request completed: operation=publish protocol=HTTP/1.1

I'll try to make it less noisy and merge it with data logs you suggested

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've missed operation in the format.


except requests.exceptions.ConnectionError as e:
raise PubNubException(
pn_error=PNERR_CONNECTION_ERROR,
Expand Down
4 changes: 3 additions & 1 deletion pubnub/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ def __init__(self, headers, pn_config):


class ResponseInfo(object):
def __init__(self, status_code, tls_enabled, origin, uuid, auth_key, client_request, client_response=None):
def __init__(self, status_code, tls_enabled, origin, uuid, auth_key, client_request,
client_response=None, http_version=None):
self.status_code = status_code
self.tls_enabled = tls_enabled
self.origin = origin
self.uuid = uuid
self.auth_key = auth_key
self.client_request = client_request
self.client_response = client_response
self.http_version = http_version


class Envelope(object):
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ flake8>=7.1.2
pytest>=8.3.5
pytest-asyncio>=1.0.0
httpx>=0.28
h2>=4.1
h2>=4.3
Comment thread
parfeon marked this conversation as resolved.
requests>=2.32.2
aiohttp>=3.10.11
cbor2>=5.6
Expand Down
Loading