Skip to content

Commit

Permalink
log analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanxin committed Oct 7, 2023
1 parent 0b87fce commit f52deb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/analysis/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ func (a *Analysis) RunAnalysis() {
if len(a.Filters) == 0 && len(activeFilters) == 0 {
var wg sync.WaitGroup
var mutex sync.Mutex
for _, analyzer := range coreAnalyzerMap {
for key, analyzer := range coreAnalyzerMap {
fmt.Printf("analyzer %s\n", key)
wg.Add(1)
semaphore <- struct{}{}
go func(analyzer common.IAnalyzer, wg *sync.WaitGroup, semaphore chan struct{}) {
defer wg.Done()
results, err := analyzer.Analyze(analyzerConfig)
if err != nil {
mutex.Lock()
fmt.Printf("analyzer err: %s\n", err.Error())
a.Errors = append(a.Errors, fmt.Sprintf("[%s] %s", reflect.TypeOf(analyzer).Name(), err))
mutex.Unlock()
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/server/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (h *handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) (
if int(i.MaxConcurrency) == 0 {
i.MaxConcurrency = 10
}
fmt.Println("before create analysis")
analysis, err := analysis.NewAnalysis(
i.Backend,
i.Language,
Expand All @@ -35,7 +34,9 @@ func (h *handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) (
int(i.MaxConcurrency),
false, // Kubernetes Doc disabled in server mode
)
fmt.Printf("before create analysis %s, %s \n", analysis.AnalysisAIProvider, analysis.Namespace)
if err != nil {
fmt.Printf("create analysis %s", err.Error())
return &schemav1.AnalyzeResponse{}, err
}
fmt.Println("before run analysis")
Expand All @@ -44,7 +45,11 @@ func (h *handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) (

fmt.Println("after run analysis")
for _, result := range analysis.Results {
fmt.Printf("result: %s", result.Details)
fmt.Printf("result: %s\n", result.Name)
}

for _, error := range analysis.Errors {
fmt.Printf("error: %s\n", error)
}

if i.Explain {
Expand Down

0 comments on commit f52deb6

Please sign in to comment.