Skip to content

Commit b5b9f17

Browse files
committed
chore: skip logging for streaming rest RPCs
1 parent 8ceeaae commit b5b9f17

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class {{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
256256
{% endif %}{# method.lro #}
257257
{#- TODO(https://github.com/googleapis/gapic-generator-python/issues/2274): Add debug log before intercepting a request #}
258258
resp = self._interceptor.post_{{ method.name|snake_case }}(resp)
259+
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2279): Add logging support for rest streaming. #}
260+
{% if not method.server_streaming %}
259261
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
260262
http_response = {
261263
"payload": {% if method.output.ident.is_proto_plus_type %}{{ method.output.ident }}.to_json(resp){% else %}json_format.MessageToJson(resp){% endif %},
@@ -272,6 +274,7 @@ class {{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
272274
"httpResponse": http_response,
273275
},
274276
)
277+
{% endif %}{# if not method.server_streaming #}
275278
return resp
276279

277280
{% endif %}{# method.void #}

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest_asyncio.py.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ class Async{{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
217217
json_format.Parse(content, pb_resp, ignore_unknown_fields=True)
218218
{% endif %}{# if method.server_streaming #}
219219
resp = await self._interceptor.post_{{ method.name|snake_case }}(resp)
220+
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2279): Add logging support for rest streaming. #}
221+
{% if not method.server_streaming %}
220222
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER
221223
http_response = {
222224
"payload": {% if method.output.ident.is_proto_plus_type %}{{ method.output.ident }}.to_json(response){% else %}json_format.MessageToJson(response){% endif %},
@@ -232,7 +234,7 @@ class Async{{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
232234
"httpResponse": http_response,
233235
},
234236
)
235-
237+
{% endif %}{# if not method.server_streaming #}
236238
return resp
237239

238240
{% endif %}{# method.void #}

tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,6 @@ async def __call__(self,
817817
"httpResponse": http_response,
818818
},
819819
)
820-
821820
return resp
822821

823822
class _DeleteInstance(_BaseCloudRedisRestTransport._BaseDeleteInstance, AsyncCloudRedisRestStub):
@@ -934,7 +933,6 @@ async def __call__(self,
934933
"httpResponse": http_response,
935934
},
936935
)
937-
938936
return resp
939937

940938
class _ExportInstance(_BaseCloudRedisRestTransport._BaseExportInstance, AsyncCloudRedisRestStub):
@@ -1054,7 +1052,6 @@ async def __call__(self,
10541052
"httpResponse": http_response,
10551053
},
10561054
)
1057-
10581055
return resp
10591056

10601057
class _FailoverInstance(_BaseCloudRedisRestTransport._BaseFailoverInstance, AsyncCloudRedisRestStub):
@@ -1174,7 +1171,6 @@ async def __call__(self,
11741171
"httpResponse": http_response,
11751172
},
11761173
)
1177-
11781174
return resp
11791175

11801176
class _GetInstance(_BaseCloudRedisRestTransport._BaseGetInstance, AsyncCloudRedisRestStub):
@@ -1288,7 +1284,6 @@ async def __call__(self,
12881284
"httpResponse": http_response,
12891285
},
12901286
)
1291-
12921287
return resp
12931288

12941289
class _GetInstanceAuthString(_BaseCloudRedisRestTransport._BaseGetInstanceAuthString, AsyncCloudRedisRestStub):
@@ -1402,7 +1397,6 @@ async def __call__(self,
14021397
"httpResponse": http_response,
14031398
},
14041399
)
1405-
14061400
return resp
14071401

14081402
class _ImportInstance(_BaseCloudRedisRestTransport._BaseImportInstance, AsyncCloudRedisRestStub):
@@ -1522,7 +1516,6 @@ async def __call__(self,
15221516
"httpResponse": http_response,
15231517
},
15241518
)
1525-
15261519
return resp
15271520

15281521
class _ListInstances(_BaseCloudRedisRestTransport._BaseListInstances, AsyncCloudRedisRestStub):
@@ -1638,7 +1631,6 @@ async def __call__(self,
16381631
"httpResponse": http_response,
16391632
},
16401633
)
1641-
16421634
return resp
16431635

16441636
class _RescheduleMaintenance(_BaseCloudRedisRestTransport._BaseRescheduleMaintenance, AsyncCloudRedisRestStub):
@@ -1758,7 +1750,6 @@ async def __call__(self,
17581750
"httpResponse": http_response,
17591751
},
17601752
)
1761-
17621753
return resp
17631754

17641755
class _UpdateInstance(_BaseCloudRedisRestTransport._BaseUpdateInstance, AsyncCloudRedisRestStub):
@@ -1878,7 +1869,6 @@ async def __call__(self,
18781869
"httpResponse": http_response,
18791870
},
18801871
)
1881-
18821872
return resp
18831873

18841874
class _UpgradeInstance(_BaseCloudRedisRestTransport._BaseUpgradeInstance, AsyncCloudRedisRestStub):
@@ -1998,7 +1988,6 @@ async def __call__(self,
19981988
"httpResponse": http_response,
19991989
},
20001990
)
2001-
20021991
return resp
20031992

20041993
@property

0 commit comments

Comments
 (0)