Skip to content

Commit 33f36e0

Browse files
authored
Merge pull request #413 from Scale3-Labs/development
Fix Sending User feedback
2 parents 3755dc6 + 7582a27 commit 33f36e0

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/langtrace_python_sdk/utils/with_root_span.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
limitations under the License.
1515
"""
1616

17+
import base64
1718
import asyncio
1819
import os
1920
from deprecated import deprecated
@@ -145,7 +146,9 @@ class SendUserFeedback:
145146
_langtrace_api_key: str
146147

147148
def __init__(self):
148-
self._langtrace_host = os.environ.get("LANGTRACE_API_HOST", LANGTRACE_REMOTE_URL)
149+
self._langtrace_host = os.environ.get(
150+
"LANGTRACE_API_HOST", LANGTRACE_REMOTE_URL
151+
)
149152
# When the host is set to /api/trace, remove the /api/trace
150153
if self._langtrace_host.endswith("/api/trace"):
151154
self._langtrace_host = self._langtrace_host.replace("/api/trace", "")
@@ -162,14 +165,13 @@ def evaluate(self, data: EvaluationAPIData) -> None:
162165
print(Fore.RESET)
163166
return
164167

165-
# convert spanId and traceId to hexadecimals
166-
span_hex_number = hex(int(data["spanId"], 10))[2:] # Convert to hex and remove the '0x' prefix
167-
formatted_span_hex_number = span_hex_number.zfill(16) # Pad with zeros to 16 characters
168-
data["spanId"] = f"0x{formatted_span_hex_number}"
168+
# convert spanId and traceId to Base64
169+
span_bytes = int(data["spanId"], 10).to_bytes(8, "big")
170+
data["spanId"] = base64.b64encode(span_bytes).decode("ascii")
169171

170-
trace_hex_number = hex(int(data["traceId"], 10))[2:] # Convert to hex and remove the '0x' prefix
171-
formatted_trace_hex_number = trace_hex_number.zfill(32) # Pad with zeros to 32 characters
172-
data["traceId"] = f"0x{formatted_trace_hex_number}"
172+
# Convert traceId to base64
173+
trace_bytes = int(data["traceId"], 10).to_bytes(16, "big")
174+
data["traceId"] = base64.b64encode(trace_bytes).decode("ascii")
173175

174176
evaluation = self.get_evaluation(data["spanId"])
175177
headers = {"x-api-key": self._langtrace_api_key}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.3.7"
1+
__version__ = "3.3.8"

0 commit comments

Comments
 (0)