From 5e1d70191223f40f142cfd6634ed4ffdfc2b17a5 Mon Sep 17 00:00:00 2001 From: BryanFauble <17128019+BryanFauble@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:52:44 -0700 Subject: [PATCH 1/2] Attach the user.id of the logged in user to the trace span --- synapseclient/core/credentials/credential_provider.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/synapseclient/core/credentials/credential_provider.py b/synapseclient/core/credentials/credential_provider.py index 29b804bc0..e2910e90e 100644 --- a/synapseclient/core/credentials/credential_provider.py +++ b/synapseclient/core/credentials/credential_provider.py @@ -7,6 +7,8 @@ import os from typing import TYPE_CHECKING, Dict, Tuple, Union +from opentelemetry import trace + from synapseclient.api import get_config_authentication from synapseclient.core.credentials.cred_data import ( SynapseAuthTokenCredentials, @@ -92,6 +94,9 @@ def _create_synapse_credential( credentials.username = profile_username credentials.displayname = profile_displayname credentials.owner_id = profile.get("ownerId", None) + current_span = trace.get_current_span() + if current_span.is_recording(): + current_span.set_attribute("user.id", syn.credentials.owner_id) return credentials From a90581b90fd1dbe975f843b9b638955ad41e594e Mon Sep 17 00:00:00 2001 From: BryanFauble <17128019+BryanFauble@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:01:26 -0700 Subject: [PATCH 2/2] Correction --- synapseclient/core/credentials/credential_provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapseclient/core/credentials/credential_provider.py b/synapseclient/core/credentials/credential_provider.py index e2910e90e..0acf2e9d0 100644 --- a/synapseclient/core/credentials/credential_provider.py +++ b/synapseclient/core/credentials/credential_provider.py @@ -96,7 +96,7 @@ def _create_synapse_credential( credentials.owner_id = profile.get("ownerId", None) current_span = trace.get_current_span() if current_span.is_recording(): - current_span.set_attribute("user.id", syn.credentials.owner_id) + current_span.set_attribute("user.id", credentials.owner_id) return credentials