func generateSpans()

in pkg/tracegen/otlp.go [106:131]


func generateSpans(ctx context.Context, tracer trace.Tracer, stats *EventStats) (context.Context, error) {
	now := time.Now()
	ctx, parent := tracer.Start(ctx,
		"parent",
		trace.WithSpanKind(trace.SpanKindServer),
		trace.WithTimestamp(now),
	)
	defer parent.End(trace.WithTimestamp(now.Add(time.Millisecond * 1500)))
	stats.SpansSent++

	_, child1 := tracer.Start(ctx, "child1", trace.WithTimestamp(now.Add(time.Millisecond*500)))
	time.Sleep(10 * time.Millisecond)
	child1.AddEvent("an arbitrary event")
	child1.End(trace.WithTimestamp(now.Add(time.Second * 1)))
	stats.SpansSent++
	stats.LogsSent++ // span event is captured as a log

	_, child2 := tracer.Start(ctx, "child2", trace.WithTimestamp(now.Add(time.Millisecond*600)))
	time.Sleep(10 * time.Millisecond)
	child2.RecordError(errors.New("an exception occurred"))
	child2.End(trace.WithTimestamp(now.Add(time.Millisecond * 1300)))
	stats.SpansSent++
	stats.ExceptionsSent++ // error captured as an error/exception log event

	return ctx, nil
}