Skip to content

Commit e340ce8

Browse files
authored
Add links and events to tracing payload (#21)
* add links * remove test artifact * add templated events and links * use random factor for rates & merge defaults+random * making linking to previous span a default until we can support specific linkage * lint * fix template example, rename defaults * oops forgot to undo testing
1 parent a3ee42a commit e340ce8

File tree

4 files changed

+428
-12
lines changed

4 files changed

+428
-12
lines changed

examples/template/template.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const client = new tracing.Client({
2121
const traceDefaults = {
2222
attributeSemantics: tracing.SEMANTICS_HTTP,
2323
attributes: {"one": "three"},
24-
randomAttributes: {count: 2, cardinality: 5}
24+
randomAttributes: {count: 2, cardinality: 5},
25+
randomEvents: {generateExceptionOnError: true, rate: 1.0, randomAttributes: {count: 2, cardinality: 3}},
26+
randomLinks: {rate: 1.0, randomAttributes: {count: 2, cardinality: 3}},
2527
}
2628

2729
const traceTemplates = [
@@ -63,6 +65,16 @@ const traceTemplates = [
6365
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}},
6466
]
6567
},
68+
{
69+
defaults: traceDefaults,
70+
spans: [
71+
{service: "shop-backend", attributes: {"http.status_code": 403}},
72+
{service: "shop-backend", name: "authenticate", attributes: {"http.request.header.accept": ["application/json"]}},
73+
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}},
74+
{service: "cart-service", name: "checkout", randomEvents: {exceptionRate: 1, rate: 2, randomAttributes: {count: 5, cardinality: 2}}},
75+
{service: "billing-service", name: "payment", randomLinks: {rate: 2, randomAttributes: {count: 3, cardinality: 2}}}
76+
]
77+
},
6678
]
6779

6880
export default function () {

pkg/tracegen/parameterized.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ func (g *ParameterizedGenerator) generateSpan(t *TraceParams, dest ptrace.Span)
114114
event := span.Events().AppendEmpty()
115115
event.SetName(random.K6String(12))
116116
event.SetTimestamp(pcommon.NewTimestampFromTime(startTime))
117-
event.Attributes().PutStr(random.K6String(12), random.K6String(12))
117+
event.Attributes().PutStr(random.K6String(5), random.K6String(12))
118+
119+
link := span.Links().AppendEmpty()
120+
link.SetTraceID(traceID)
121+
link.SetSpanID(random.SpanID())
122+
link.Attributes().PutStr(random.K6String(12), random.K6String(12))
118123

119124
status := span.Status()
120125
status.SetCode(1)

0 commit comments

Comments
 (0)