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

Function TestQueryTrace

cmd/tempo-vulture/main_test.go:293–379  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291type traceOps func(*tempopb.Trace)
292
293func TestQueryTrace(t *testing.T) {
294 noOp := func(_ *tempopb.Trace) {}
295 setMissingSpan := func(trace *tempopb.Trace) {
296 trace.ResourceSpans[0].ScopeSpans[0].Spans[0].ParentSpanId = []byte{'t', 'e', 's', 't'}
297 }
298 setNoBatchesSpan := func(trace *tempopb.Trace) {
299 trace.ResourceSpans = make([]*v1.ResourceSpans, 0)
300 }
301 setAlteredSpan := func(trace *tempopb.Trace) {
302 trace.ResourceSpans[0].ScopeSpans[0].Spans[0].Name = "Different spam"
303 }
304 tests := []struct {
305 name string
306 traceOperation func(*tempopb.Trace)
307 err error
308 expectedMetrics traceMetrics
309 expectedError error
310 }{
311 {
312 name: "assert querytrace yields an unexpected error",
313 traceOperation: noOp,
314 err: errors.New("unexpected error"),
315 expectedMetrics: traceMetrics{
316 requested: 1,
317 requestFailed: 1,
318 },
319 expectedError: errors.New("unexpected error"),
320 },
321 {
322 name: "assert querytrace yields traceNotFound error",
323 traceOperation: noOp,
324 err: util.ErrTraceNotFound,
325 expectedMetrics: traceMetrics{
326 requested: 1,
327 notFoundByID: 1,
328 },
329 expectedError: util.ErrTraceNotFound,
330 },
331 {
332 name: "assert querytrace for ok trace",
333 traceOperation: noOp,
334 err: nil,
335 expectedMetrics: traceMetrics{
336 requested: 1,
337 },
338 expectedError: nil,
339 },
340 {
341 name: "assert querytrace for a trace with missing spans",
342 traceOperation: setMissingSpan,
343 err: nil,
344 expectedMetrics: traceMetrics{
345 requested: 1,
346 missingSpans: 1,
347 },
348 expectedError: nil,
349 },
350 {

Callers

nothing calls this directly

Calls 3

doQueryTraceFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected