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

Method makeThriftBatch

pkg/util/trace_info.go:164–204  ·  view source on GitHub ↗
(traceIDHigh, traceIDLow int64)

Source from the content-addressed store, hash-verified

162}
163
164func (t *TraceInfo) makeThriftBatch(traceIDHigh, traceIDLow int64) *jaeger.Batch {
165 var spans []*jaeger.Span
166 count := t.generateRandomInt(1, 5)
167 lastSpanID, nextSpanID := int64(0), int64(0)
168
169 // Each span has the previous span as parent, creating a tree with a single branch per batch.
170 for i := int64(0); i < count; i++ {
171 nextSpanID = t.r.Int63()
172
173 spanTags := t.generateRandomTagsWithPrefix("vulture")
174 spanTags = append(spanTags, t.generateFixedAttributesWithPrefix("vulture")...)
175 spanTags = append(spanTags, t.generateSpanWellKnownAttributes()...)
176
177 spans = append(spans, &jaeger.Span{
178 TraceIdLow: traceIDLow,
179 TraceIdHigh: traceIDHigh,
180 SpanId: nextSpanID,
181 ParentSpanId: lastSpanID,
182 OperationName: fmt.Sprintf("vulture-%d", t.generateRandomInt(0, 100)),
183 References: nil,
184 Flags: 0,
185 StartTime: t.timestamp.UnixMicro(),
186 Duration: t.generateRandomInt(0, 100),
187 Tags: spanTags,
188 Logs: t.generateRandomLogs(),
189 })
190
191 lastSpanID = nextSpanID
192 }
193
194 processTags := t.generateRandomTagsWithPrefix("vulture-process")
195 processTags = append(processTags, t.generateFixedAttributesWithPrefix("vulture-process")...)
196 processTags = append(processTags, t.generateResourceWellKnownAttributes()...)
197
198 process := &jaeger.Process{
199 ServiceName: "tempo-vulture",
200 Tags: processTags,
201 }
202
203 return &jaeger.Batch{Process: process, Spans: spans}
204}
205
206func (t *TraceInfo) generateRandomString() string {
207 letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Callers 2

EmitBatchesMethod · 0.95

Tested by

no test coverage detected