Skip to content

Commit 876f211

Browse files
chore: update log adapter to support session-scoped api method logging
Updates `log_adapter` to optionally store API method names in a `Session` instance instead of the global list. This improves label accuracy when running tests in parallel. - Updates `Session` to initialize `_api_methods` list and lock. - Updates `log_adapter.add_api_method` and `get_and_reset_api_methods` to handle session-scoped logging. - Updates `log_adapter.method_logger` and `property_logger` to identify the session from arguments. - Propagates `session` through `start_query_with_client` and its callers to ensure labels are correctly associated with the session.
1 parent da37742 commit 876f211

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bigframes/core/log_adapter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,16 @@ def add_api_method(api_method_name, session=None):
256256
global _lock
257257
global _api_methods
258258

259+
clean_method_name = api_method_name.replace("<", "").replace(">", "")
260+
259261
if session is not None:
260262
with session._api_methods_lock:
261-
session._api_methods.insert(
262-
0, api_method_name.replace("<", "").replace(">", "")
263-
)
263+
session._api_methods.insert(0, clean_method_name)
264264
session._api_methods = session._api_methods[:MAX_LABELS_COUNT]
265265
else:
266266
with _lock:
267267
# Push the method to the front of the _api_methods list
268-
_api_methods.insert(0, api_method_name.replace("<", "").replace(">", ""))
268+
_api_methods.insert(0, clean_method_name)
269269
# Keep the list length within the maximum limit (adjust MAX_LABELS_COUNT as needed)
270270
_api_methods = _api_methods[:MAX_LABELS_COUNT]
271271

0 commit comments

Comments
 (0)