Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FDS-2458] Attach the user.id of the logged in user to the trace span #1143

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions synapseclient/core/credentials/credential_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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", credentials.owner_id)

return credentials

Expand Down
Loading