Skip to content

Commit

Permalink
Fix panic in metrics service in collector
Browse files Browse the repository at this point in the history
There is no metrics partitioner running in collector.  This service
needs to be reworked since it has ingestor specific bits in it that
are not relevant for collector to run.
  • Loading branch information
jwilder committed Aug 25, 2023
1 parent 2d0ec6a commit 9a3fd04
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions metrics/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,20 @@ func (s *service) collect(ctx context.Context) {
case <-ctx.Done():
return
case <-t.C:
// Only one node should execute the cardinality counts so see if we are the owner.
hostname, _ := s.partitioner.Owner([]byte("AdxmonIngestorTableCardinalityCount"))
if s.kustoCli != nil && hostname == s.hostname {
stmt := kusto.NewStmt("", kusto.UnsafeStmt(unsafe.Stmt{Add: true, SuppressWarning: true})).UnsafeAdd(
".set-or-append async AdxmonIngestorTableCardinalityCount <| CountCardinality",
)
iter, err := s.kustoCli.Mgmt(ctx, s.database, stmt)
if err != nil {
logger.Error("Failed to execute cardinality counts: %s", err)
} else {
iter.Stop()
// This is only set when running on ingestor currently.
if s.partitioner != nil {
// Only one node should execute the cardinality counts so see if we are the owner.
hostname, _ := s.partitioner.Owner([]byte("AdxmonIngestorTableCardinalityCount"))
if s.kustoCli != nil && hostname == s.hostname {
stmt := kusto.NewStmt("", kusto.UnsafeStmt(unsafe.Stmt{Add: true, SuppressWarning: true})).UnsafeAdd(
".set-or-append async AdxmonIngestorTableCardinalityCount <| CountCardinality",
)
iter, err := s.kustoCli.Mgmt(ctx, s.database, stmt)
if err != nil {
logger.Error("Failed to execute cardinality counts: %s", err)
} else {
iter.Stop()
}
}
}

Expand Down

0 comments on commit 9a3fd04

Please sign in to comment.