Skip to content

Commit

Permalink
Add links and events to tracing payload (#21)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ie-pham authored Jan 17, 2024
1 parent a3ee42a commit e340ce8
Show file tree
Hide file tree
Showing 4 changed files with 428 additions and 12 deletions.
14 changes: 13 additions & 1 deletion examples/template/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const client = new tracing.Client({
const traceDefaults = {
attributeSemantics: tracing.SEMANTICS_HTTP,
attributes: {"one": "three"},
randomAttributes: {count: 2, cardinality: 5}
randomAttributes: {count: 2, cardinality: 5},
randomEvents: {generateExceptionOnError: true, rate: 1.0, randomAttributes: {count: 2, cardinality: 3}},
randomLinks: {rate: 1.0, randomAttributes: {count: 2, cardinality: 3}},
}

const traceTemplates = [
Expand Down Expand Up @@ -63,6 +65,16 @@ const traceTemplates = [
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}},
]
},
{
defaults: traceDefaults,
spans: [
{service: "shop-backend", attributes: {"http.status_code": 403}},
{service: "shop-backend", name: "authenticate", attributes: {"http.request.header.accept": ["application/json"]}},
{service: "auth-service", name: "authenticate", attributes: {"http.status_code": 403}},
{service: "cart-service", name: "checkout", randomEvents: {exceptionRate: 1, rate: 2, randomAttributes: {count: 5, cardinality: 2}}},
{service: "billing-service", name: "payment", randomLinks: {rate: 2, randomAttributes: {count: 3, cardinality: 2}}}
]
},
]

export default function () {
Expand Down
7 changes: 6 additions & 1 deletion pkg/tracegen/parameterized.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ func (g *ParameterizedGenerator) generateSpan(t *TraceParams, dest ptrace.Span)
event := span.Events().AppendEmpty()
event.SetName(random.K6String(12))
event.SetTimestamp(pcommon.NewTimestampFromTime(startTime))
event.Attributes().PutStr(random.K6String(12), random.K6String(12))
event.Attributes().PutStr(random.K6String(5), random.K6String(12))

link := span.Links().AppendEmpty()
link.SetTraceID(traceID)
link.SetSpanID(random.SpanID())
link.Attributes().PutStr(random.K6String(12), random.K6String(12))

status := span.Status()
status.SetCode(1)
Expand Down
Loading

0 comments on commit e340ce8

Please sign in to comment.