@@ -118,43 +118,6 @@ func TestUnmatchedAuto(t *testing.T) {
118118 }
119119}
120120
121- func TestIgnoreRoutes (t * testing.T ) {
122- input := msg.NewQueue [[]request.Span ](msg .ChannelBufferLen (10 ))
123- output := msg.NewQueue [[]request.Span ](msg .ChannelBufferLen (10 ))
124- router , err := RoutesProvider (& RoutesConfig {
125- Unmatch : UnmatchPath , Patterns : []string {"/user/:id" , "/v1/metrics" },
126- IgnorePatterns : []string {"/v1/metrics/*" , "/v1/traces/*" , "/exact" },
127- },
128- input , output )(t .Context ())
129- require .NoError (t , err )
130- out := output .Subscribe ()
131- defer input .Close ()
132- go router (t .Context ())
133- input .Send ([]request.Span {{Path : "/user/1234" }})
134- input .Send ([]request.Span {{Path : "/v1/metrics" }}) // this is in routes and ignore, ignore takes precedence
135- input .Send ([]request.Span {{Path : "/v1/traces/1234/test" }})
136- input .Send ([]request.Span {{Path : "/v1/metrics/1234/test" }}) // this is in routes and ignore, ignore takes precedence
137- input .Send ([]request.Span {{Path : "/v1/traces" }})
138- input .Send ([]request.Span {{Path : "/exact" }})
139- input .Send ([]request.Span {{Path : "/some/path" }})
140- assert .Equal (t , []request.Span {{
141- Path : "/user/1234" ,
142- Route : "/user/:id" ,
143- }}, filterIgnored (func () []request.Span { return testutil .ReadChannel (t , out , testTimeout ) }))
144- assert .Equal (t , []request.Span {{
145- Path : "/some/path" ,
146- Route : "/some/path" ,
147- }}, filterIgnored (func () []request.Span { return testutil .ReadChannel (t , out , testTimeout ) }))
148- }
149-
150- func TestIgnoreMode (t * testing.T ) {
151- s := request.Span {Path : "/user/1234" }
152- setSpanIgnoreMode (IgnoreTraces , & s )
153- assert .True (t , s .IgnoreTraces ())
154- setSpanIgnoreMode (IgnoreMetrics , & s )
155- assert .True (t , s .IgnoreMetrics ())
156- }
157-
158121func BenchmarkRoutesProvider_Wildcard (b * testing.B ) {
159122 benchProvider (b , UnmatchWildcard )
160123}
@@ -188,27 +151,3 @@ func benchProvider(b *testing.B, unmatch UnmatchType) {
188151 <- outCh
189152 }
190153}
191-
192- func filterIgnored (reader func () []request.Span ) []request.Span {
193- for {
194- input := reader ()
195- output := make ([]request.Span , 0 , len (input ))
196- for i := range input {
197- s := & input [i ]
198-
199- if s .IgnoreMetrics () {
200- continue
201- }
202-
203- if s .IgnoreTraces () {
204- continue
205- }
206-
207- output = append (output , * s )
208- }
209-
210- if len (output ) > 0 {
211- return output
212- }
213- }
214- }
0 commit comments