Repository: googleapis/python-pubsub

Issue:
Log when a new `stream_ack_deadline_seconds` is sent on the StreamingPull BiDi stream
We can do an info-level log whenever the value changes: https://github.com/googleapis/python-pubsub/blob/6fa03be779d6a7105bb7c029b95d4c357d2a49df/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L742

It may help debug issues. More generally, we might want to log changes in critical parameters like [changes](https://github.com/googleapis/python-pubsub/blob/6fa03be779d6a7105bb7c029b95d4c357d2a49df/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L366) in the ack deadline (which depends on recent delivery-to-ack durations).

Discussion:

Patch:
diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
index ae36358..894c41b 100644
--- a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
+++ b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
@@ -743,6 +743,9 @@ class StreamingPullManager(object):
                 request = gapic_types.StreamingPullRequest(
                     stream_ack_deadline_seconds=self.ack_deadline
                 )
+                _LOGGER.info(
+                    "Sending new ack_deadline of %d seconds.", self.ack_deadline
+                )
             else:
                 request = gapic_types.StreamingPullRequest()
 


Test patch:
diff --git a/tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py b/tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py
index 8a14609..ad16471 100644
--- a/tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py
+++ b/tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py
@@ -1035,7 +1035,8 @@ def test_heartbeat_inactive():
     assert not result
 
 
-def test_heartbeat_stream_ack_deadline_seconds():
+def test_heartbeat_stream_ack_deadline_seconds(caplog):
+    caplog.set_level(logging.INFO)
     manager = make_manager()
     manager._rpc = mock.create_autospec(bidi.BidiRpc, instance=True)
     manager._rpc.is_active = True
@@ -1050,6 +1051,7 @@ def test_heartbeat_stream_ack_deadline_seconds():
     assert result
     # Set to false after a send is initiated.
     assert not manager._send_new_ack_deadline
+    assert "Sending new ack_deadline of 10 seconds." in caplog.text
 
 
 @mock.patch("google.api_core.bidi.ResumableBidiRpc", autospec=True)