Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mssql: fix not collecting sql errors #1793

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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