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 3 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},
eventDefaults: {generateExceptionOnError: true, count: 1.0, randomAttributes: {count: 2, cardinality: 3}},
linkDefaults: {linkToPreviousSpanIndex: true, count: 1.0, randomAttributes: {count: 2, cardinality: 3}},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was not adjusted to the latest changes

}

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: "test-random", name: "events", randomEvents: {exceptionCount: 1, count: 2, randomAttributes: {count: 5, cardinality: 2}}},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this template the span and service names etc. mimic traces from a somewhat plausible e-commerce service landscape. It would be good to keep this and choose less generic service (test-random) and span names (links, events) here

{service: "test-random", name: "links", randomLinks: {linkToPreviousSpanIndex: true, count: 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