Skip to content

Commit

Permalink
database_observability: add debug info to collectors
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
cristiangreco committed Feb 21, 2025
1 parent d0a7dd2 commit 215d610
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ func (c *ConnectionInfo) Stop() {
c.Registry.Unregister(c.InfoMetric)
c.running.Store(false)
}

func (c *ConnectionInfo) DebugInfo() interface{} {
return map[string]string{}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,7 @@ func (c *QuerySample) fetchQuerySamples(ctx context.Context) error {

return nil
}

func (c *QuerySample) DebugInfo() interface{} {
return map[string]string{}
}
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,10 @@ func (c *SchemaTable) fetchColumnsDefinitions(ctx context.Context, schemaName st

return tblSpec, nil
}

func (c *SchemaTable) DebugInfo() interface{} {
m := map[string]interface{}{
"cache_size": c.cache.Len(),
}
return m
}
12 changes: 12 additions & 0 deletions internal/component/database_observability/mysql/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ var (
_ component.Component = (*Component)(nil)
_ http_service.Component = (*Component)(nil)
_ component.HealthComponent = (*Component)(nil)
_ component.DebugComponent = (*Component)(nil)
)

type Collector interface {
Name() string
Start(context.Context) error
Stopped() bool
Stop()
DebugInfo() interface{}
}

type Component struct {
Expand Down Expand Up @@ -374,3 +376,13 @@ func formatDSN(dsn string, params ...string) string {
}
return dsn + strings.Join(params, "&")
}

func (c *Component) DebugInfo() interface{} {
m := map[string]interface{}{
"collectors": c.collectors,
}
for _, collector := range c.collectors {
m["collector:"+collector.Name()] = collector.DebugInfo()
}
return m
}

0 comments on commit 215d610

Please sign in to comment.