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

Function TestHostInfo

modules/generator/processor/hostinfo/processor_test.go:21–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func 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
59func TestHostInfoHostSource(t *testing.T) {
60 testRegistry := registry.NewTestRegistry()

Callers

nothing calls this directly

Calls 10

QueryMethod · 0.95
NewTestRegistryFunction · 0.92
MakeBatchFunction · 0.92
NewFunction · 0.70
NewCounterMethod · 0.65
NameMethod · 0.65
ShutdownMethod · 0.65
PushSpansMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected