(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestHostInfo(t *testing.T) { |
| 22 | testRegistry := registry.NewTestRegistry() |
| 23 | cfg := Config{} |
| 24 | |
| 25 | cfg.RegisterFlagsAndApplyDefaults("", nil) |
| 26 | p, err := New(cfg, testRegistry, nil, prometheus.NewCounter(prometheus.CounterOpts{})) |
| 27 | require.NoError(t, err) |
| 28 | require.Equal(t, p.Name(), processor.HostInfoName) |
| 29 | defer p.Shutdown(context.TODO()) |
| 30 | |
| 31 | req := &tempopb.PushSpansRequest{ |
| 32 | Batches: []*trace_v1.ResourceSpans{ |
| 33 | test.MakeBatch(10, nil), |
| 34 | test.MakeBatch(10, nil), |
| 35 | }, |
| 36 | } |
| 37 | |
| 38 | for i, b := range req.Batches { |
| 39 | b.Resource.Attributes = append(b.Resource.Attributes, []*common_v1.KeyValue{ |
| 40 | {Key: "host.id", Value: &common_v1.AnyValue{Value: &common_v1.AnyValue_StringValue{StringValue: "test" + strconv.Itoa(i)}}}, |
| 41 | }...) |
| 42 | } |
| 43 | |
| 44 | p.PushSpans(context.Background(), req) |
| 45 | |
| 46 | lbls0 := labels.FromMap(map[string]string{ |
| 47 | hostIdentifierAttr: "test0", |
| 48 | hostSourceAttr: "host.id", |
| 49 | }) |
| 50 | assert.Equal(t, 1.0, testRegistry.Query(hostInfoMetric, lbls0)) |
| 51 | |
| 52 | lbls1 := labels.FromMap(map[string]string{ |
| 53 | hostIdentifierAttr: "test1", |
| 54 | hostSourceAttr: "host.id", |
| 55 | }) |
| 56 | assert.Equal(t, 1.0, testRegistry.Query(hostInfoMetric, lbls1)) |
| 57 | } |
| 58 | |
| 59 | func TestHostInfoHostSource(t *testing.T) { |
| 60 | testRegistry := registry.NewTestRegistry() |
nothing calls this directly
no test coverage detected