1- // Package ` diagnostics` provides some tools useful for gathering and
1+ // Package diagnostics provides some tools useful for gathering and
22// exposing arbitrary diagnositcs information for external monitoring tools.
33//
44// Possible usage: integration nodes list into dashboard
@@ -18,21 +18,21 @@ var logger = log.Logger("keep-diagnostics")
1818
1919// Registry performs all management of diagnostic. Specifically, it allows
2020// to registering new diagnostics sources and exposing them through the diagnostics server.
21- type DiagnosticsRegistry struct {
21+ type Registry struct {
2222 diagnosticsSources map [string ]func () string
2323 diagnosticsMutex sync.RWMutex
2424}
2525
2626// NewRegistry creates a new metrics registry.
27- func NewRegistry () * DiagnosticsRegistry {
28- return & DiagnosticsRegistry {
27+ func NewRegistry () * Registry {
28+ return & Registry {
2929 diagnosticsSources : make (map [string ]func () string ),
3030 }
3131}
3232
3333// EnableServer enables the diagnostics server on the given port. Data will
3434// be exposed on `/diagnostics` path in JSON format.
35- func (r * DiagnosticsRegistry ) EnableServer (port int ) {
35+ func (r * Registry ) EnableServer (port int ) {
3636 server := & http.Server {Addr : ":" + strconv .Itoa (port )}
3737
3838 http .HandleFunc ("/diagnostics" , func (response http.ResponseWriter , _ * http.Request ) {
@@ -48,20 +48,20 @@ func (r *DiagnosticsRegistry) EnableServer(port int) {
4848 }()
4949}
5050
51- // Registers diagnostics source callback with a given name.
51+ // RegisterSource registers diagnostics source callback with a given name.
5252// Name will be used as a key and callback result as a value in JSON object
53- // during composing diagnostics JSON.
54- // Note: function will override existing diagnostics source on attempt
53+ // during composing diagnostics JSON.
54+ // Note: function will override existing diagnostics source on attempt
5555// to register another one with the same name.
56- func (r * DiagnosticsRegistry ) RegisterSource (name string , source func () string ) {
56+ func (r * Registry ) RegisterSource (name string , source func () string ) {
5757 r .diagnosticsMutex .Lock ()
5858 defer r .diagnosticsMutex .Unlock ()
5959
6060 r .diagnosticsSources [name ] = source
6161}
6262
6363// Exposes all registered diagnostics sources in a single JSON document.
64- func (r * DiagnosticsRegistry ) exposeDiagnostics () string {
64+ func (r * Registry ) exposeDiagnostics () string {
6565 r .diagnosticsMutex .RLock ()
6666 defer r .diagnosticsMutex .RUnlock ()
6767
0 commit comments