mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* [Generator] Add DRAIN span_name sanitizer * Fix linter * Fix formatting * Update default manifest * Fix build error in update-fixtures * Remove bad test * Remove misleading comment * Add per-tenant override for drain mode * Do a machines job * Address PR feedback * Address PR review: rename drain_mode config and improve sanitizer - Rename `drain_mode` to `span_name_sanitization` across all config, legacy config, interfaces, and overrides for better user-facing clarity - Add explicit default value "disabled" in RegisterFlagsAndApplyDefaults - Add ValidateSpanNameSanitization function in validation/fields.go - Rename metrics to remove DRAIN reference: `drain_spans_compacted_total` -> `spans_sanitized_total` `post_drain_demand_estimate` -> `post_sanitization_demand_estimate` - Pass configured staleDuration to NewDrainSanitizer instead of hardcoded 15min, consistent with other registry components - Extract "span_name" magic string to labelSpanName constant - Update all tests with new names and signatures * Update manifest * Use empty string as disabled * Update CHANGELOG.md Co-authored-by: Suraj Nath <[email protected]> * Update manifest --------- Co-authored-by: Suraj Nath <[email protected]>
44 lines
827 B
Go
44 lines
827 B
Go
package drain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func BenchmarkDrain_TrainExtractsPatterns(b *testing.B) {
|
|
tests := []struct {
|
|
inputFile string
|
|
}{
|
|
{inputFile: `dev1.json`},
|
|
{inputFile: `ops1.json`},
|
|
{inputFile: `prod1.json`},
|
|
{inputFile: `prod2.json`},
|
|
{inputFile: `prod3.json`},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
b.Run(tt.inputFile, func(b *testing.B) {
|
|
linesJSON, err := os.ReadFile(filepath.Join("testdata", tt.inputFile))
|
|
require.NoError(b, err)
|
|
|
|
var lines []string
|
|
err = json.Unmarshal(linesJSON, &lines)
|
|
require.NoError(b, err)
|
|
|
|
drain := New("test-tenant", DefaultConfig())
|
|
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
for _, line := range lines {
|
|
drain.Train(line)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|