Skip to content

Commit

Permalink
mssql: fix not collecting sql errors (#1793)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke authored Nov 30, 2024
1 parent 71e5e5e commit f5ff75e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/collector/mssql/mssql_sql_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const (
func (c *Collector) buildSQLErrors() error {
var err error

c.genStatsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
c.sqlErrorsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
errs := make([]error, 0, len(c.mssqlInstances))
counters := []string{
sqlErrorsErrorsPerSec,
}

for sqlInstance := range c.mssqlInstances {
c.genStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), perfdata.InstancesAll, counters)
c.sqlErrorsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), perfdata.InstancesAll, counters)
if err != nil {
errs = append(errs, fmt.Errorf("failed to create SQL Errors collector for instance %s: %w", sqlInstance, err))
}
Expand All @@ -63,7 +63,7 @@ func (c *Collector) buildSQLErrors() error {
}

func (c *Collector) collectSQLErrors(ch chan<- prometheus.Metric) error {
return c.collect(ch, subCollectorSQLErrors, c.dbReplicaPerfDataCollectors, c.collectSQLErrorsInstance)
return c.collect(ch, subCollectorSQLErrors, c.sqlErrorsPerfDataCollectors, c.collectSQLErrorsInstance)
}

func (c *Collector) collectSQLErrorsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/collector/mssql/mssql_sql_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const (
func (c *Collector) buildSQLStats() error {
var err error

c.genStatsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
c.sqlStatsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
errs := make([]error, 0, len(c.mssqlInstances))
counters := []string{
sqlStatsAutoParamAttemptsPerSec,
Expand All @@ -74,7 +74,7 @@ func (c *Collector) buildSQLStats() error {
}

for sqlInstance := range c.mssqlInstances {
c.genStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"), nil, counters)
c.sqlStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"), nil, counters)
if err != nil {
errs = append(errs, fmt.Errorf("failed to create SQL Statistics collector for instance %s: %w", sqlInstance, err))
}
Expand Down

0 comments on commit f5ff75e

Please sign in to comment.