Skip to content

Commit 162a058

Browse files
authored
[FDS-2458] Attach the user.id of the logged in user to the trace span (#1143)
* Attach the user.id of the logged in user to the trace span
1 parent 455bb13 commit 162a058

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

synapseclient/core/credentials/credential_provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import os
88
from typing import TYPE_CHECKING, Dict, Tuple, Union
99

10+
from opentelemetry import trace
11+
1012
from synapseclient.api import get_config_authentication
1113
from synapseclient.core.credentials.cred_data import (
1214
SynapseAuthTokenCredentials,
@@ -92,6 +94,9 @@ def _create_synapse_credential(
9294
credentials.username = profile_username
9395
credentials.displayname = profile_displayname
9496
credentials.owner_id = profile.get("ownerId", None)
97+
current_span = trace.get_current_span()
98+
if current_span.is_recording():
99+
current_span.set_attribute("user.id", credentials.owner_id)
95100

96101
return credentials
97102

0 commit comments

Comments
 (0)