working telemetry v0

This commit is contained in:
Dinesh Yeduguru 2024-11-22 09:22:48 -08:00
parent d790be28b3
commit 9cebac8a3c
10 changed files with 196 additions and 101 deletions

View file

@ -20,7 +20,7 @@ from llama_stack.apis.telemetry import * # noqa: F403
log = logging.getLogger(__name__)
def generate_short_uuid(len: int = 12):
def generate_short_uuid(len: int = 8):
full_uuid = uuid.uuid4()
uuid_bytes = full_uuid.bytes
encoded = base64.urlsafe_b64encode(uuid_bytes)
@ -130,7 +130,7 @@ async def start_trace(name: str, attributes: Dict[str, Any] = None):
log.info("No Telemetry implementation set. Skipping trace initialization...")
return
trace_id = generate_short_uuid()
trace_id = generate_short_uuid(16)
context = TraceContext(BACKGROUND_LOGGER, trace_id)
context.push_span(name, {"__root__": True, **(attributes or {})})