Skip to content

Commit

Permalink
chore(go): export fields in ProfilingInfo structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Nov 19, 2024
1 parent 18b2f1a commit 9ab962a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions go/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ func (s *Scanner) Scan(buf []byte) (*ScanResults, error) {
}

type ProfilingInfo struct {
namespace string
rule string
patternMatchingTime float64
conditionExecTime float64
Namespace string
Rule string
PatternMatchingTime float64
ConditionExecTime float64
}

// This is the callback called by yrx_rule_iter_patterns.
Expand All @@ -269,10 +269,10 @@ func mostExpensiveRulesCallback(
panic("mostExpensiveRulesCallback didn't receive a *[]ProfilingInfo")
}
*profilingInfo = append(*profilingInfo, ProfilingInfo{
namespace: C.GoString(namespace),
rule: C.GoString(rule),
patternMatchingTime: float64(patternMatchingTime),
conditionExecTime: float64(condExecTime),
Namespace: C.GoString(namespace),
Rule: C.GoString(rule),
PatternMatchingTime: float64(patternMatchingTime),
ConditionExecTime: float64(condExecTime),
})
}

Expand Down
8 changes: 4 additions & 4 deletions go/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func TestScannerMostExpensiveRules(t *testing.T) {
_, err := s.Scan(bytes.Repeat([]byte("a"), 5000))
assert.NoError(t, err)
profilingInfo := s.MostExpensiveRules(1)
assert.Equal(t, "t", profilingInfo[0].rule)
assert.Equal(t, "default", profilingInfo[0].namespace)
assert.Greater(t, profilingInfo[0].patternMatchingTime, float64(0))
assert.Greater(t, profilingInfo[0].conditionExecTime, float64(0))
assert.Equal(t, "t", profilingInfo[0].Rule)
assert.Equal(t, "default", profilingInfo[0].Namespace)
assert.Greater(t, profilingInfo[0].PatternMatchingTime, float64(0))
assert.Greater(t, profilingInfo[0].ConditionExecTime, float64(0))
}

func TestScannerMetadata(t *testing.T) {
Expand Down

0 comments on commit 9ab962a

Please sign in to comment.