mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
naming changes
This commit is contained in:
parent
a7de2f3ce4
commit
4a64099243
2 changed files with 6 additions and 6 deletions
|
@ -239,7 +239,7 @@ class TracingMiddleware:
|
|||
|
||||
trace_context = await start_trace(trace_path, {"__location__": "server", "raw_path": path})
|
||||
|
||||
async def send_wrapper(message):
|
||||
async def send_with_trace_id(message):
|
||||
if message["type"] == "http.response.start":
|
||||
headers = message.get("headers", [])
|
||||
headers.append([b"x-trace-id", str(trace_context.trace_id).encode()])
|
||||
|
@ -247,7 +247,7 @@ class TracingMiddleware:
|
|||
await send(message)
|
||||
|
||||
try:
|
||||
return await self.app(scope, receive, send_wrapper)
|
||||
return await self.app(scope, receive, send_with_trace_id)
|
||||
finally:
|
||||
await end_trace()
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ INVALID_SPAN_ID = 0x0000000000000000
|
|||
INVALID_TRACE_ID = 0x00000000000000000000000000000000
|
||||
|
||||
|
||||
def format_trace_id(trace_id: int) -> str:
|
||||
def trace_id_to_str(trace_id: int) -> str:
|
||||
"""Convenience trace ID formatting method
|
||||
Args:
|
||||
trace_id: Trace ID int
|
||||
|
@ -45,7 +45,7 @@ def format_trace_id(trace_id: int) -> str:
|
|||
return format(trace_id, "032x")
|
||||
|
||||
|
||||
def format_span_id(span_id: int) -> str:
|
||||
def span_id_to_str(span_id: int) -> str:
|
||||
"""Convenience span ID formatting method
|
||||
Args:
|
||||
span_id: Span ID int
|
||||
|
@ -60,14 +60,14 @@ def generate_span_id() -> str:
|
|||
span_id = random.getrandbits(64)
|
||||
while span_id == INVALID_SPAN_ID:
|
||||
span_id = random.getrandbits(64)
|
||||
return format_span_id(span_id)
|
||||
return span_id_to_str(span_id)
|
||||
|
||||
|
||||
def generate_trace_id() -> str:
|
||||
trace_id = random.getrandbits(128)
|
||||
while trace_id == INVALID_TRACE_ID:
|
||||
trace_id = random.getrandbits(128)
|
||||
return format_trace_id(trace_id)
|
||||
return trace_id_to_str(trace_id)
|
||||
|
||||
|
||||
CURRENT_TRACE_CONTEXT = contextvars.ContextVar("trace_context", default=None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue