Skip to main content

Crate polaris_dashboard

Crate polaris_dashboard 

Source
Expand description

Opinionated read-only dashboard for Polaris sessions.

Register DashboardPlugin on a polaris_ai::system::server::Server to mount the bundled SvelteKit SPA at a configurable base path. The dashboard is read-only and consumes session, run, and span data exposed by HttpPlugin and TracingPlugin.

The SPA is not built by this crate. It must be compiled and built in its own repository; the build output is dropped into assets/ and embedded at compile time via rust-embed. With an empty assets/, the crate still compiles and every dashboard route returns a “bundle missing” notice instead of the UI.

§Required backend plugins

The SPA calls /v1/sessions/* (mounted by HttpPlugin) and /v1/tracing/* (mounted by TracingPlugin when its dashboard feature is active). Per the upstream plugin stack, that requires:

  • ServerInfoPlugin (foundation)
  • AppPlugin (HTTP router)
  • ModelsPlugin, ToolsPlugin (transitive deps of TracingPlugin when dashboard is on)
  • SessionsPlugin + HttpPlugin (sessions REST surface)
  • TracingPlugin (the /v1/tracing/* runs / span-tree endpoints)

SpanStorePlugin is optional but recommended for restart-safe run history. Hosts that omit TracingPlugin will see “Failed to load runs: 404” in the runs pane — the bundled examples/serve.rs is a minimal complete wiring.

§Replacing the SPA

This crate is framework-agnostic: it embeds whatever static bundle lives in assets/ and serves it: index.html at the base path, embedded files for matching sub-paths, and index.html as the fallback for everything else (client-side routing). It does no templating and injects no config. Any framework (React, Vue, Solid, plain HTML, …) works in place of the bundled SvelteKit SPA as long as the bundle satisfies this contract:

  1. Client-routed, rooted at index.html — there is no SSR; unmatched paths under the base return index.html verbatim.
  2. Asset URLs resolve under the mount base — the SPA’s build-time base must equal DashboardPlugin’s base_path (the bundled SPA is built for /dashboard). A mismatch 404s every asset; DashboardPlugin logs a warning when it can detect one.
  3. Same-origin, relative API calls to the documented contracts: /v1/sessions/* (from HttpPlugin) and /v1/tracing/* (from TracingPlugin or OtelTracingPlugin), consuming the RunSummary / SpanTree JSON shapes. The host supplies no API base — the SPA assumes same origin.
  4. No host-injected configuration — the SPA must self-configure.

§Auth

Authentication is driven by whatever AuthProvider the host server registers on polaris_ai::app::HttpRouter::set_auth. The dashboard plugin does not register its own provider — its routes inherit the global middleware applied by polaris_ai::app::AppPlugin.

§Example

use std::sync::Arc;
use polaris_ai::app::{AppConfig, AppPlugin};
use polaris_ai::sessions::{HttpPlugin, InMemoryStore, SessionsPlugin};
use polaris_ai::system::server::Server;
use polaris_dashboard::DashboardPlugin;

let mut server = Server::new();
server
    .add_plugins(AppPlugin::new(AppConfig::new()))
    .add_plugins(SessionsPlugin::new(Arc::new(InMemoryStore::new())))
    .add_plugins(HttpPlugin::new())
    .add_plugins(DashboardPlugin::default());
server.run().await?;

Structs§

Configuring
Typestate marker: the store is still being configured. Retention knobs (with_capacity, with_ttl, with_persistence) are available, but the plugin is not a Plugin yet and cannot be mounted until build seals it into Ready.
DashboardPlugin
Plugin that serves the bundled Polaris sessions dashboard SPA over HTTP.
OtelTracingPlugin
Turns the dashboard into a standalone OTLP viewer.
Ready
Typestate marker: the store is built and the plugin is ready to mount. This is the default state — OtelTracingPlugin means OtelTracingPlugin<Ready>, so every existing reference and add_plugins call is unaffected.
RunSummary
One row in the runs list (GET /v1/tracing/runs).
RunsResponse
Envelope for the runs list.
SpanEvent
One event nested inside a SpanNode.
SpanNode
One node in a SpanTree.
SpanTree
Hierarchical view of one run (GET /v1/tracing/runs/{id}).
TraceStore
Bounded, thread-safe store of OTel traces.

Constants§

DEFAULT_CAPACITY
Default number of distinct traces retained in memory.

Traits§

StoreState
Typestate of an OtelTracingPlugin — whether its TraceStore has been built yet. Sealed: the only states are Configuring and Ready.