Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add links and events to tracing payload #21

Merged
merged 8 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading