diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 8d152fb..46d301f 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -12,13 +12,13 @@ jobs: - name: Set-up Go uses: actions/setup-go@v3 with: - go-version: ^1.21 + go-version: ^1.22 cache: true - name: Lint uses: golangci/golangci-lint-action@v3 with: - version: v1.55.2 + version: v1.59.0 args: --config ./golangci.yml - name: Test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afa2745..146024b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Set-up Go uses: actions/setup-go@v3 with: - go-version: ^1.19 + go-version: ^1.22 cache: true - name: Test diff --git a/Dockerfile b/Dockerfile index d976ded..a16159a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine AS xk6-client-tracing-build +FROM golang:1.22-alpine AS xk6-client-tracing-build RUN apk add --no-cache \ build-base \ @@ -7,7 +7,7 @@ RUN apk add --no-cache \ make RUN go install go.k6.io/xk6/cmd/xk6@latest \ - && wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.0 \ + && wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.59.0 \ && golangci-lint --version WORKDIR /opt/xk6-client-tracing diff --git a/examples/template/template.js b/examples/template/template.js index 1f6d17f..452387f 100644 --- a/examples/template/template.js +++ b/examples/template/template.js @@ -13,7 +13,7 @@ const client = new tracing.Client({ endpoint, exporter: tracing.EXPORTER_OTLP, tls: { - insecure: true, + insecure: true, }, headers: { "X-Scope-Orgid": orgid @@ -24,8 +24,7 @@ const traceDefaults = { attributeSemantics: tracing.SEMANTICS_HTTP, attributes: {"one": "three"}, 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}}, + randomEvents: {count: 0.1, exceptionCount: 0.2, randomAttributes: {count: 6, cardinality: 20}}, } const traceTemplates = [ @@ -36,7 +35,11 @@ const traceTemplates = [ {service: "shop-backend", name: "authenticate", duration: {min: 50, max: 100}}, {service: "auth-service", name: "authenticate"}, {service: "shop-backend", name: "fetch-articles", parentIdx: 0}, - {service: "article-service", name: "list-articles"}, + { + service: "article-service", + name: "list-articles", + links: [{attributes: {"link-type": "parent-child"}, randomAttributes: {count: 2, cardinality: 5}}] + }, {service: "article-service", name: "select-articles", attributeSemantics: tracing.SEMANTICS_DB}, {service: "postgres", name: "query-articles", attributeSemantics: tracing.SEMANTICS_DB, randomAttributes: {count: 5}}, ] @@ -45,6 +48,7 @@ const traceTemplates = [ defaults: { attributes: {"numbers": ["one", "two", "three"]}, attributeSemantics: tracing.SEMANTICS_HTTP, + randomEvents: {count: 2, randomAttributes: {count: 3, cardinality: 10}}, }, spans: [ {service: "shop-backend", name: "article-to-cart", duration: {min: 400, max: 1200}}, @@ -64,17 +68,30 @@ const traceTemplates = [ 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: "auth-service", + name: "authenticate", + attributes: {"http.status_code": 403}, + randomEvents: {count: 0.5, exceptionCount: 2, randomAttributes: {count: 5, cardinality: 5}} + }, ] }, { defaults: traceDefaults, spans: [ - {service: "shop-backend", attributes: {"http.status_code": 403}}, + {service: "shop-backend"}, {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}}} + {service: "auth-service", name: "authenticate"}, + { + service: "cart-service", + name: "checkout", + randomEvents: {count: 0.5, exceptionCount: 2, exceptionOnError: true, randomAttributes: {count: 5, cardinality: 5}} + }, + { + service: "billing-service", + name: "payment", + randomLinks: {count: 0.5, randomAttributes: {count: 3, cardinality: 10}}, + randomEvents: {exceptionOnError: true, randomAttributes: {count: 4}}} ] }, ] @@ -89,4 +106,4 @@ export default function () { export function teardown() { client.shutdown(); -} +} \ No newline at end of file diff --git a/pkg/random/random.go b/pkg/random/random.go index 8f68ea0..ff3dc6d 100644 --- a/pkg/random/random.go +++ b/pkg/random/random.go @@ -32,6 +32,10 @@ func init() { rnd = rand.New(rand.NewSource(seed.Int64())) } +func Rand() *rand.Rand { + return rnd +} + func SelectElement[T any](elements []T) T { return elements[rnd.Intn(len(elements))] } @@ -121,3 +125,7 @@ func SpanID() pcommon.SpanID { _, _ = rnd.Read(b[:]) // always returns nil error return b } + +func EventName() string { + return "event_k6." + String(10) +} diff --git a/pkg/tracegen/templated.go b/pkg/tracegen/templated.go index 4e75dac..4dc03dd 100644 --- a/pkg/tracegen/templated.go +++ b/pkg/tracegen/templated.go @@ -2,7 +2,6 @@ package tracegen import ( "fmt" - "math/rand" "net/http" "net/url" "strings" @@ -52,9 +51,9 @@ type SpanDefaults struct { // RandomAttributes random attributes generated for each span. RandomAttributes *AttributeParams `js:"randomAttributes"` // Random events generated for each span - RandomEvents EventParams `js:"randomEvents"` + RandomEvents *EventParams `js:"randomEvents"` // Random links generated for each span - RandomLinks LinkParams `js:"randomLinks"` + RandomLinks *LinkParams `js:"randomLinks"` } // SpanTemplate parameters that define how a span is created. @@ -82,9 +81,9 @@ type SpanTemplate struct { // List of links for the span with specific parameters Links []Link `js:"links"` // Generate random events for the span - RandomEvents EventParams `js:"randomEvents"` + RandomEvents *EventParams `js:"randomEvents"` // Generate random links for the span - RandomLinks LinkParams `js:"randomLinks"` + RandomLinks *LinkParams `js:"randomLinks"` } // TraceTemplate describes how all a trace and it's spans are generated. @@ -112,35 +111,23 @@ type Event struct { } type LinkParams struct { - // Rate of random links per each span - Rate float32 `js:"rate"` + // Count of random links per each span (default: 1) + Count float32 `js:"count"` // Generate random attributes for this link RandomAttributes *AttributeParams `js:"randomAttributes"` } type EventParams struct { - // Generate exception event if status code of the span is >= 400 - GenerateExceptionOnError bool `js:"generateExceptionOnError"` - // Rate of exception events per each span - ExceptionRate float32 `js:"exceptionRate"` - // Rate of random events per each span - Rate float32 `js:"rate"` + // Count of random events per each span + Count float32 `js:"count"` + // ExceptionCount indicates how many exception events to add to the span + ExceptionCount float32 `js:"exceptionCount"` + // ExceptionOnError generates exceptions if status code of the span is >= 400 + ExceptionOnError bool `js:"exceptionOnError"` // Generate random attributes for this event RandomAttributes *AttributeParams `js:"randomAttributes"` } -type internalLinkParams struct { - Count int - RandomAttributes *AttributeParams -} - -type internalEventParams struct { - GenerateExceptionOnError bool - ExceptionCount int - Count int - RandomAttributes *AttributeParams -} - // NewTemplatedGenerator creates a new trace generator. func NewTemplatedGenerator(template *TraceTemplate) (*TemplatedGenerator, error) { gen := &TemplatedGenerator{} @@ -161,18 +148,17 @@ type TemplatedGenerator struct { } type internalSpanTemplate struct { - idx int - resource *internalResourceTemplate - parent *internalSpanTemplate - name string - kind ptrace.SpanKind - duration *Range - attributeSemantics *OTelSemantics - attributes map[string]interface{} - randomAttributes map[string][]interface{} - events []Event - links []Link - generateExceptionEvents bool + idx int + resource *internalResourceTemplate + parent *internalSpanTemplate + name string + kind ptrace.SpanKind + duration *Range + attributeSemantics *OTelSemantics + attributes map[string]interface{} + randomAttributes map[string][]interface{} + events []internalEventTemplate + links []internalLinkTemplate } type internalResourceTemplate struct { @@ -183,6 +169,20 @@ type internalResourceTemplate struct { hostPort int } +type internalLinkTemplate struct { + rate float32 + attributes map[string]interface{} + randomAttributes map[string][]interface{} +} + +type internalEventTemplate struct { + rate float32 + exceptionOnError bool + name string + attributes map[string]interface{} + randomAttributes map[string][]interface{} +} + // Traces implements Generator for TemplatedGenerator func (g *TemplatedGenerator) Traces() ptrace.Traces { var ( @@ -288,49 +288,56 @@ func (g *TemplatedGenerator) generateSpan(scopeSpans ptrace.ScopeSpans, tmpl *in } } - // events + // generate events + var hasError bool + if st, found := span.Attributes().Get("http.status_code"); found { + hasError = st.Int() >= 400 + } else if st, found = span.Attributes().Get("http.response.status_code"); found { + hasError = st.Int() >= 400 + } span.Events().EnsureCapacity(len(tmpl.events)) for _, e := range tmpl.events { - event := span.Events().AppendEmpty() - event.SetName(e.Name) - event.SetTimestamp(pcommon.NewTimestampFromTime(end)) - for k, v := range e.Attributes { - _ = event.Attributes().PutEmpty(k).FromRaw(v) + if e.rate > 0 && random.Rand().Float32() > e.rate { + continue } - } - - if tmpl.generateExceptionEvents { - var status int64 - parentAttr := pcommon.NewMap() - if parent != nil { - parentAttr = parent.Attributes() + if e.exceptionOnError && !hasError { + continue } - if st, found := span.Attributes().Get("http.status_code"); found { - status = st.Int() - } else if st, found = parentAttr.Get("http.status_code"); found { - status = st.Int() - } else { - status = random.HTTPStatusSuccess() - span.Attributes().PutInt("http.status_code", status) + + event := span.Events().AppendEmpty() + event.Attributes().EnsureCapacity(len(e.attributes) + len(e.randomAttributes)) + + event.SetName(e.name) + eventTime := start.Add(random.Duration(0, duration)) + event.SetTimestamp(pcommon.NewTimestampFromTime(eventTime)) + + for k, v := range e.attributes { + _ = event.Attributes().PutEmpty(k).FromRaw(v) } - if status >= 400 { - exceptionEvent := generateExceptionEvent() - event := span.Events().AppendEmpty() - event.SetName(exceptionEvent.Name) - event.SetTimestamp(pcommon.NewTimestampFromTime(end)) - for k, v := range exceptionEvent.Attributes { - _ = event.Attributes().PutEmpty(k).FromRaw(v) - } + for k, v := range e.randomAttributes { + _ = event.Attributes().PutEmpty(k).FromRaw(random.SelectElement(v)) } } - // links + // generate links span.Links().EnsureCapacity(len(tmpl.links)) for _, l := range tmpl.links { + if l.rate > 0 && random.Rand().Float32() > l.rate { + continue + } + link := span.Links().AppendEmpty() - // default to linking to previous span if exist - // maybe we will be able support linking to specific spans in the future + link.Attributes().EnsureCapacity(len(l.attributes) + len(l.randomAttributes)) + for k, v := range l.randomAttributes { + _ = link.Attributes().PutEmpty(k).FromRaw(random.SelectElement(v)) + } + for k, v := range l.attributes { + _ = link.Attributes().PutEmpty(k).FromRaw(v) + } + + // default to linking to parent span if exist + // TODO: support linking to other existing spans if parent != nil { link.SetTraceID(traceID) link.SetSpanID(parent.SpanID()) @@ -338,9 +345,6 @@ func (g *TemplatedGenerator) generateSpan(scopeSpans ptrace.ScopeSpans, tmpl *in link.SetTraceID(random.TraceID()) link.SetSpanID(random.SpanID()) } - for k, v := range l.Attributes { - _ = link.Attributes().PutEmpty(k).FromRaw(v) - } } return span @@ -524,70 +528,6 @@ func (g *TemplatedGenerator) initializeSpan(idx int, parent *internalSpanTemplat } span.attributes = util.MergeMaps(defaults.Attributes, tmpl.Attributes) - eventDefaultsRate := defaults.RandomEvents.Rate - var eventDefaults internalEventParams - // if rate is more than 1, use whole integers - if eventDefaultsRate > 1 { - eventDefaults = internalEventParams{ - GenerateExceptionOnError: defaults.RandomEvents.GenerateExceptionOnError, - RandomAttributes: defaults.RandomEvents.RandomAttributes, - Count: int(eventDefaultsRate), - ExceptionCount: int(defaults.RandomEvents.ExceptionRate), - } - } else { - var count, exeptionCount int - if rand.Float32() < eventDefaultsRate { - count = 1 - } - - if rand.Float32() < eventDefaultsRate { - exeptionCount = 1 - } - - // if rate is less than one - eventDefaults = internalEventParams{ - GenerateExceptionOnError: defaults.RandomEvents.GenerateExceptionOnError, - RandomAttributes: defaults.RandomEvents.RandomAttributes, - Count: count, - ExceptionCount: exeptionCount, - } - } - - randomEvents := internalEventParams{ - GenerateExceptionOnError: tmpl.RandomEvents.GenerateExceptionOnError, - RandomAttributes: tmpl.RandomEvents.RandomAttributes, - Count: int(tmpl.RandomEvents.Rate), - ExceptionCount: int(tmpl.RandomEvents.ExceptionRate), - } - - // generate all non-exception events - span.events = g.initializeEvents(tmpl.Events, randomEvents, eventDefaults) - - // need span status to determine if an exception event should occur - span.generateExceptionEvents = defaults.RandomEvents.GenerateExceptionOnError - - linkDefaultsRate := defaults.RandomLinks.Rate - var linkDefaults internalLinkParams - if linkDefaultsRate > 1 { - linkDefaults = internalLinkParams{ - RandomAttributes: defaults.RandomLinks.RandomAttributes, - Count: int(linkDefaultsRate), - } - } else if rand.Float32() < linkDefaultsRate { - linkDefaults = internalLinkParams{ - RandomAttributes: defaults.RandomLinks.RandomAttributes, - Count: 1, - } - } - - randomLinks := internalLinkParams{ - Count: int(tmpl.RandomLinks.Rate), - RandomAttributes: tmpl.RandomEvents.RandomAttributes, - } - - // initialize all links but need - span.links = g.initializeLinks(tmpl.Links, randomLinks, linkDefaults) - // set span name if tmpl.Name != nil { span.name = *tmpl.Name @@ -603,6 +543,12 @@ func (g *TemplatedGenerator) initializeSpan(idx int, parent *internalSpanTemplat span.randomAttributes = initializeRandomAttributes(tmpl.RandomAttributes) + // initialize links for span + span.links = g.initializeLinks(tmpl.Links, tmpl.RandomLinks, defaults.RandomLinks) + + // initialize events for the span + span.events = g.initializeEvents(tmpl.Events, tmpl.RandomEvents, defaults.RandomEvents) + return &span, nil } @@ -683,69 +629,81 @@ func initializeRandomAttributes(attributeParams *AttributeParams) map[string][]i return attributes } -func (g *TemplatedGenerator) initializeEvents(tmplEvents []Event, randomEvents internalEventParams, eventDefaults internalEventParams) []Event { - count := len(tmplEvents) + randomEvents.Count + eventDefaults.Count - - if count == 0 { - return []Event{} - } - - events := make([]Event, 0, count) - +func (g *TemplatedGenerator) initializeEvents(tmplEvents []Event, randomEvents, defaultRandomEvents *EventParams) []internalEventTemplate { + internalEvents := make([]internalEventTemplate, 0, len(tmplEvents)) for _, e := range tmplEvents { - event := generateEvent(e.Name, e.Attributes, e.RandomAttributes) - events = append(events, event) - } - - for i := 0; i < randomEvents.ExceptionCount; i++ { - event := generateExceptionEvent() - events = append(events, event) + event := internalEventTemplate{ + name: e.Name, + attributes: e.Attributes, + randomAttributes: initializeRandomAttributes(e.RandomAttributes), + } + internalEvents = append(internalEvents, event) } - for i := 0; i < randomEvents.Count; i++ { - event := generateEvent("", nil, randomEvents.RandomAttributes) - events = append(events, event) + if randomEvents == nil { + if defaultRandomEvents == nil { + return internalEvents + } + randomEvents = defaultRandomEvents } - for i := 0; i < eventDefaults.Count; i++ { - event := generateEvent("", nil, eventDefaults.RandomAttributes) - events = append(events, event) + // normal random events + if randomEvents.Count == 0 { // default count is 1 + randomEvents.Count = 1 } - - return events -} - -func generateExceptionEvent() Event { - return Event{ - Name: "exception", - Attributes: map[string]interface{}{ - "exception.escape": false, - "exception.message": generateRandomExceptionMsg(), - "exception.stacktrace": generateRandomExceptionStackTrace(), - "exception.type": random.K6String(10) + ".error", - }, + if randomEvents.Count < 1 { + event := internalEventTemplate{ + rate: randomEvents.Count, + name: random.EventName(), + randomAttributes: initializeRandomAttributes(randomEvents.RandomAttributes), + } + internalEvents = append(internalEvents, event) + } else { + for i := 0; i < int(randomEvents.Count); i++ { + event := internalEventTemplate{ + name: random.EventName(), + randomAttributes: initializeRandomAttributes(randomEvents.RandomAttributes), + } + internalEvents = append(internalEvents, event) + } } -} -func generateEvent(name string, attributes map[string]interface{}, randomAttr *AttributeParams) Event { - event := Event{ - Attributes: make(map[string]interface{}), + // random exception events + if randomEvents.ExceptionCount == 0 && randomEvents.ExceptionOnError { + randomEvents.ExceptionCount = 1 // default exception count is 1, if ExceptionOnError is true } - - if name != "" { - event.Name = name + if randomEvents.ExceptionCount < 1 { + event := internalEventTemplate{ + rate: randomEvents.ExceptionCount, + name: "exception", + attributes: map[string]interface{}{ + "exception.escape": false, + "exception.message": generateRandomExceptionMsg(), + "exception.stacktrace": generateRandomExceptionStackTrace(), + "exception.type": "error.type_" + random.K6String(10), + }, + randomAttributes: initializeRandomAttributes(randomEvents.RandomAttributes), + exceptionOnError: randomEvents.ExceptionOnError, + } + internalEvents = append(internalEvents, event) } else { - event.Name = "event " + random.K6String(10) - } - - for k, v := range attributes { - event.Attributes[k] = v + for i := 0; i < int(randomEvents.ExceptionCount); i++ { + event := internalEventTemplate{ + name: "exception", + attributes: map[string]interface{}{ + "exception.escape": false, + "exception.message": generateRandomExceptionMsg(), + "exception.stacktrace": generateRandomExceptionStackTrace(), + "exception.type": "error.type_" + random.K6String(10), + }, + randomAttributes: initializeRandomAttributes(randomEvents.RandomAttributes), + exceptionOnError: randomEvents.ExceptionOnError, + } + internalEvents = append(internalEvents, event) + } } - for k, v := range initializeRandomAttributes(randomAttr) { - event.Attributes[k] = random.SelectElement(v) - } - return event + return internalEvents } func generateRandomExceptionMsg() string { @@ -761,46 +719,41 @@ func generateRandomExceptionStackTrace() string { return "panic: " + random.SelectElement(panics) + "\n" + random.SelectElement(functions) } -func (g *TemplatedGenerator) initializeLinks(tmplLinks []Link, randomLinks internalLinkParams, linkDefaults internalLinkParams) []Link { - count := len(tmplLinks) + randomLinks.Count + linkDefaults.Count +func (g *TemplatedGenerator) initializeLinks(linkTemplates []Link, randomLinks, defaultRandomLinks *LinkParams) []internalLinkTemplate { + internalLinks := make([]internalLinkTemplate, 0, len(linkTemplates)) - if count == 0 { - return []Link{} - } - - links := make([]Link, 0, count) - newLink := func() *Link { - return &Link{ - Attributes: make(map[string]interface{}), + for _, lt := range linkTemplates { + link := internalLinkTemplate{ + attributes: lt.Attributes, + randomAttributes: initializeRandomAttributes(lt.RandomAttributes), } + internalLinks = append(internalLinks, link) } - for _, l := range tmplLinks { - link := newLink() - for k, v := range l.Attributes { - link.Attributes[k] = v - } - for k, v := range initializeRandomAttributes(l.RandomAttributes) { - link.Attributes[k] = random.SelectElement(v) + if randomLinks == nil { + if defaultRandomLinks == nil { + return internalLinks } - links = append(links, *link) + randomLinks = defaultRandomLinks } - - for i := 0; i < randomLinks.Count; i++ { - link := newLink() - for k, v := range initializeRandomAttributes(randomLinks.RandomAttributes) { - link.Attributes[k] = random.SelectElement(v) - } - links = append(links, *link) + if randomLinks.Count == 0 { // default count is 1 + randomLinks.Count = 1 } - for i := 0; i < linkDefaults.Count; i++ { - link := newLink() - for k, v := range initializeRandomAttributes(linkDefaults.RandomAttributes) { - link.Attributes[k] = random.SelectElement(v) + if randomLinks.Count < 1 { + link := internalLinkTemplate{ + rate: randomLinks.Count, + randomAttributes: initializeRandomAttributes(randomLinks.RandomAttributes), + } + internalLinks = append(internalLinks, link) + } else { + for i := 0; i < int(randomLinks.Count); i++ { + link := internalLinkTemplate{ + randomAttributes: initializeRandomAttributes(randomLinks.RandomAttributes), + } + internalLinks = append(internalLinks, link) } - links = append(links, *link) } - return links + return internalLinks } diff --git a/pkg/tracegen/templated_test.go b/pkg/tracegen/templated_test.go index a4c0033..23608bf 100644 --- a/pkg/tracegen/templated_test.go +++ b/pkg/tracegen/templated_test.go @@ -58,15 +58,15 @@ func TestTemplatedGenerator_EventsLinks(t *testing.T) { Defaults: SpanDefaults{ Attributes: map[string]interface{}{"fixed.attr": "some-value"}, RandomAttributes: &AttributeParams{Count: 3}, - RandomLinks: LinkParams{Rate: 0.5, RandomAttributes: &AttributeParams{Count: 3}}, - RandomEvents: EventParams{GenerateExceptionOnError: true, Rate: 0.5, RandomAttributes: &AttributeParams{Count: 3}}, + RandomLinks: &LinkParams{Count: 0.5, RandomAttributes: &AttributeParams{Count: 3}}, + RandomEvents: &EventParams{ExceptionOnError: true, Count: 0.5, RandomAttributes: &AttributeParams{Count: 3}}, }, Spans: []SpanTemplate{ // do not change order of the first one {Service: "test-service", Name: ptr("only_default")}, {Service: "test-service", Name: ptr("default_and_template"), Events: []Event{{Name: "event-name", RandomAttributes: &AttributeParams{Count: 2}}}, Links: []Link{{Attributes: map[string]interface{}{"link-attr-key": "link-attr-value"}}}}, - {Service: "test-service", Name: ptr("default_and_random"), RandomEvents: EventParams{Rate: 2, RandomAttributes: &AttributeParams{Count: 1}}, RandomLinks: LinkParams{Rate: 2, RandomAttributes: &AttributeParams{Count: 1}}}, - {Service: "test-service", Name: ptr("default_template_random"), Events: []Event{{Name: "event-name", RandomAttributes: &AttributeParams{Count: 2}}}, Links: []Link{{Attributes: map[string]interface{}{"link-attr-key": "link-attr-value"}}}, RandomEvents: EventParams{Rate: 2, RandomAttributes: &AttributeParams{Count: 1}}, RandomLinks: LinkParams{Rate: 2, RandomAttributes: &AttributeParams{Count: 1}}}, + {Service: "test-service", Name: ptr("default_and_random"), RandomEvents: &EventParams{Count: 2, RandomAttributes: &AttributeParams{Count: 1}}, RandomLinks: &LinkParams{Count: 2, RandomAttributes: &AttributeParams{Count: 1}}}, + {Service: "test-service", Name: ptr("default_template_random"), Events: []Event{{Name: "event-name", RandomAttributes: &AttributeParams{Count: 2}}}, Links: []Link{{Attributes: map[string]interface{}{"link-attr-key": "link-attr-value"}}}, RandomEvents: &EventParams{Count: 2, RandomAttributes: &AttributeParams{Count: 1}}, RandomLinks: &LinkParams{Count: 2, RandomAttributes: &AttributeParams{Count: 1}}}, {Service: "test-service", Name: ptr("default_generate_on_error"), Attributes: map[string]interface{}{"http.status_code": 400}}, }, } diff --git a/tracing.go b/tracing.go index 8092b7e..355142e 100644 --- a/tracing.go +++ b/tracing.go @@ -1,4 +1,4 @@ -package xk6_client_tracing +package clienttracing import ( "context"