Compare commits

...
Author SHA1 Message Date
Doğan Can Bakır 97348e02ef to err 2024-08-13 13:04:34 +03:00
Doğan Can Bakır 597f1b8e9e add debug code 2024-08-12 14:40:53 +03:00
2 changed files with 18 additions and 1 deletions

No files matched your search

+7 -1
View File
@@ -63,6 +63,7 @@ func Cluster(list []*Template) [][]*Template {
dns[hash] = []*Template{}
}
dns[hash] = append(dns[hash], template)
gologger.Error().Msgf("Clustered DNS template: %s with hash: %d", template.ID, hash)
} else {
final = append(final, []*Template{template})
}
@@ -74,6 +75,7 @@ func Cluster(list []*Template) [][]*Template {
http[hash] = []*Template{}
}
http[hash] = append(http[hash], template)
gologger.Error().Msgf("Clustered HTTP template: %s with hash: %d", template.ID, hash)
} else {
final = append(final, []*Template{template})
}
@@ -84,6 +86,7 @@ func Cluster(list []*Template) [][]*Template {
ssl[hash] = []*Template{}
}
ssl[hash] = append(ssl[hash], template)
gologger.Error().Msgf("Clustered SSL template: %s with hash: %d", template.ID, hash)
} else {
final = append(final, []*Template{template})
}
@@ -92,7 +95,7 @@ func Cluster(list []*Template) [][]*Template {
}
}
// add all clusterd templates
// add all clustered templates
for _, templates := range http {
final = append(final, templates)
}
@@ -103,6 +106,7 @@ func Cluster(list []*Template) [][]*Template {
final = append(final, templates)
}
gologger.Error().Msgf("Total clusters formed: %d", len(final))
return final
}
@@ -150,10 +154,12 @@ func ClusterTemplates(templatesList []*Template, options protocols.ExecutorOptio
TotalRequests: len(cluster[0].RequestsHTTP) + len(cluster[0].RequestsDNS),
})
clusterCount += len(cluster)
gologger.Error().Msgf("Created cluster with ID: %s containing %d templates", clusterID, len(cluster))
} else {
finalTemplatesList = append(finalTemplatesList, cluster...)
}
}
gologger.Error().Msgf("Total templates after clustering: %d", len(finalTemplatesList))
return finalTemplatesList, clusterCount
}
+11
View File
@@ -54,6 +54,11 @@ func (s *Agent) Start(interval time.Duration) context.CancelFunc {
ticker := time.NewTicker(interval)
go func() {
defer func() {
if r := recover(); r != nil {
gologger.Error().Msgf("Recovered in Start: %v", r)
}
}()
for {
select {
case <-ctx.Done():
@@ -70,6 +75,12 @@ func (s *Agent) Start(interval time.Duration) context.CancelFunc {
// monitorWorker is a worker for monitoring running goroutines
func (s *Agent) monitorWorker(cancel context.CancelFunc) {
defer func() {
if r := recover(); r != nil {
gologger.Error().Msgf("Recovered in monitorWorker: %v", r)
}
}()
current := runtime.NumGoroutine()
if current != s.goroutineCount {
s.goroutineCount = current