@startuml
title After: Internal observability crate owns metrics and dashboard state

skinparam backgroundColor #FFFFFF
skinparam shadowing false
skinparam defaultTextAlignment center
skinparam defaultFontColor #000000
skinparam ArrowColor #333333
skinparam component {
  BackgroundColor #F7F9FC
  BorderColor #334155
  FontColor #000000
}
skinparam package {
  BackgroundColor #ECFDF5
  BorderColor #047857
  FontColor #000000
}
skinparam rectangle {
  BackgroundColor #EEF2FF
  BorderColor #3730A3
  FontColor #000000
}
skinparam database {
  BackgroundColor #FFF7ED
  BorderColor #9A3412
  FontColor #000000
}
skinparam note {
  BackgroundColor #FFFDEB
  BorderColor #A16207
  FontColor #000000
}

actor "Operator Browser" as browser
actor "Prometheus" as prometheus
component "server binary\nsrc/bin/server.rs" as server
rectangle "YAML config\nobservability.metrics" as config
rectangle "Axum middleware\nrequest timing + sizes" as middleware
package "crates/observability" as obs {
  rectangle "HttpMetrics\nPrometheus registry" as metrics
  rectangle "MetricsSnapshot\nin-memory route summary" as snapshot
  rectangle "HTML dashboard renderer" as dashboard
}
rectangle "GET /metrics\ntext exposition" as scrape
rectangle "GET /metrics/view\noperator dashboard" as view

config --> server : enables scrape path,\ndashboard path, prefix
server --> obs : constructs HttpMetrics
server --> middleware : injects Arc<HttpMetrics>
middleware --> metrics : start_request()
middleware --> metrics : finish_request(observation)
metrics --> snapshot : aggregate totals,\nerrors, latency, routes
prometheus --> scrape : GET /metrics
scrape --> metrics : encode()
browser --> view : GET /metrics/view
view --> dashboard : render_dashboard()
dashboard --> snapshot : snapshot()

note right of metrics
Collectors now include request totals,
latency, in-flight requests, status classes,
error totals, body-size histograms,
process start time, and build metadata.
end note

note bottom of view
The dashboard is still opt-in through
config.yaml and stays next to the
Prometheus scrape endpoint.
end note
@enduml
