by-framework-dashboard 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ """Dashboard UI and HTTP server for by-framework observability."""
2
+
3
+ from .dashboard import make_handler, serve
4
+
5
+ __all__ = ["make_handler", "serve"]
@@ -0,0 +1,42 @@
1
+ """Adapters from trace read SDK results to dashboard payloads."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from by_framework.metrics.snapshot import _build_trace_snapshot
8
+ from by_framework.trace import TraceReadResult
9
+
10
+
11
+ def trace_result_to_dashboard_trace(result: TraceReadResult) -> dict[str, Any]:
12
+ """Convert a TraceReadResult into the legacy dashboard trace response shape."""
13
+ trace = _build_trace_snapshot(
14
+ result.trace.trace_id,
15
+ result.trace.session_id,
16
+ [span.to_dict() for span in result.spans],
17
+ )
18
+ trace["name"] = result.trace.name
19
+ trace["input"] = result.trace.input
20
+ trace["output"] = result.trace.output
21
+ if result.trace.status:
22
+ trace["status"] = result.trace.status
23
+ trace["sources"] = result.sources
24
+ trace["diagnostics"] = [diagnostic.to_dict() for diagnostic in result.diagnostics]
25
+ return trace
26
+
27
+
28
+ def trace_result_to_dashboard_summary(result: TraceReadResult) -> dict[str, Any]:
29
+ """Convert a TraceReadResult into the legacy dashboard trace summary shape."""
30
+ trace = trace_result_to_dashboard_trace(result)
31
+ return {
32
+ "trace_id": trace.get("trace_id", ""),
33
+ "session_id": trace.get("session_id", ""),
34
+ "name": result.trace.name,
35
+ "status": trace.get("status", ""),
36
+ "start_ts": trace.get("start_ts", 0),
37
+ "end_ts": trace.get("end_ts", 0),
38
+ "duration_ms": trace.get("duration_ms", 0),
39
+ "span_count": trace.get("span_count", 0),
40
+ "sources": result.sources,
41
+ "diagnostic_count": len(result.diagnostics),
42
+ }