Generate a trace URL for a direct link to the session on the AgentOps dashboard. Args: span: The span to generate the URL for. Returns: The session URL.
(span: Union[Span, ReadableSpan])
| 9 | |
| 10 | |
| 11 | def get_trace_url(span: Union[Span, ReadableSpan]) -> str: |
| 12 | """ |
| 13 | Generate a trace URL for a direct link to the session on the AgentOps dashboard. |
| 14 | |
| 15 | Args: |
| 16 | span: The span to generate the URL for. |
| 17 | |
| 18 | Returns: |
| 19 | The session URL. |
| 20 | """ |
| 21 | trace_id: Union[int, str] = span.context.trace_id |
| 22 | |
| 23 | # Convert trace_id to hex string if it's not already |
| 24 | # We don't add dashes to this to format it as a UUID since the dashboard doesn't either |
| 25 | if isinstance(trace_id, int): |
| 26 | trace_id = format(trace_id, "032x") |
| 27 | |
| 28 | # Get the app_url from the config - import here to avoid circular imports |
| 29 | from agentops import get_client |
| 30 | |
| 31 | app_url = get_client().config.app_url |
| 32 | |
| 33 | return f"{app_url}/sessions?trace_id={trace_id}" |
| 34 | |
| 35 | |
| 36 | def log_trace_url(span: Union[Span, ReadableSpan], title: Optional[str] = None) -> None: |
searching dependent graphs…