MCPcopy
hub / github.com/grafana/tempo / TestDefaultSpansPerSpanSet

Function TestDefaultSpansPerSpanSet

modules/frontend/search_sharder_test.go:1315–1409  ·  modules/frontend/search_sharder_test.go::TestDefaultSpansPerSpanSet

TestDefaultSpansPerSpanSet verifies that the default_spans_per_span_set configuration is properly used when no spss parameter is provided in the request

(t *testing.T)

Source from the content-addressed store, hash-verified

1313// TestDefaultSpansPerSpanSet verifies that the default_spans_per_span_set configuration
1314// is properly used when no spss parameter is provided in the request
1315func TestDefaultSpansPerSpanSet(t *testing.T) {
1316 tests := []struct {
1317 name string
1318 configDefault uint32
1319 requestSpss string // empty means no spss param
1320 expectedSpss uint32
1321 maxSpansPerSpanSet uint32
1322 }{
1323 {
1324 name: "use configured default when no spss param",
1325 configDefault: 10,
1326 requestSpss: "",
1327 expectedSpss: 10,
1328 maxSpansPerSpanSet: 100,
1329 },
1330 {
1331 name: "use zero as configured default (unlimited)",
1332 configDefault: 0,
1333 requestSpss: "",
1334 expectedSpss: 0, // 0 means unlimited when explicitly configured
1335 maxSpansPerSpanSet: 0,
1336 },
1337 {
1338 name: "override configured default with request param",
1339 configDefault: 10,
1340 requestSpss: "5",
1341 expectedSpss: 5,
1342 maxSpansPerSpanSet: 100,
1343 },
1344 {
1345 name: "spss=0 in URL means unlimited when max=0",
1346 configDefault: 10,
1347 requestSpss: "0",
1348 expectedSpss: 0, // 0 means unlimited, not "return 0 spans"
1349 maxSpansPerSpanSet: 0, // max=0 means unlimited allowed
1350 },
1351 {
1352 name: "respect max_spans_per_span_set=0 (unlimited)",
1353 configDefault: 10,
1354 requestSpss: "1000",
1355 expectedSpss: 1000,
1356 maxSpansPerSpanSet: 0, // 0 means unlimited
1357 },
1358 }
1359
1360 for _, tc := range tests {
1361 t.Run(tc.name, func(t *testing.T) {
1362 // Track the actual spss value that was used
1363 var capturedSpss uint32
1364
1365 next := pipeline.AsyncRoundTripperFunc[combiner.PipelineResponse](func(r pipeline.Request) (pipeline.Responses[combiner.PipelineResponse], error) {
1366 // Parse the request to capture spss
1367 req, err := api.ParseSearchRequest(r.HTTPRequest())
1368 if err == nil {
1369 capturedSpss = req.SpansPerSpanSet
1370 }
1371 return pipeline.NewAsyncResponse(nil), nil
1372 })

Callers

nothing calls this directly

Calls 13

ContextMethod · 0.95
ParseSearchRequestFunction · 0.92
NewAsyncResponseFunction · 0.92
NewOverridesFunction · 0.92
NewHTTPRequestFunction · 0.92
newAsyncSearchSharderFunction · 0.85
newJobsPerQueryHistogramFunction · 0.85
HTTPRequestMethod · 0.65
WrapMethod · 0.65
RoundTripMethod · 0.65
NextMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected