tracegen

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeParams

type AttributeParams struct {
	// Count the number of attributes to create.
	Count int
	// Cardinality how many distinct values are created for each attribute.
	Cardinality *int
}

AttributeParams describe how random attributes should be created.

type Event

type Event struct {
	// Name of event
	Name string `js:"name"`
	// Attributes for this event
	Attributes map[string]interface{} `js:"attributes"`
	// Generate random attributes for this event
	RandomAttributes *AttributeParams `js:"randomAttributes"`
}

type EventParams

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"`
	// Generate random attributes for this event
	RandomAttributes *AttributeParams `js:"randomAttributes"`
}

type Generator

type Generator interface {
	Traces() ptrace.Traces
}

Generator creates traces to be used in k6 tests

type Link struct {
	// Attributes for this link
	Attributes map[string]interface{} `js:"attributes"`
	// Generate random attributes for this link
	RandomAttributes *AttributeParams `js:"randomAttributes"`
}

type LinkParams

type LinkParams struct {
	// Rate of random links per each span
	Rate float32 `js:"rate"`
	// Generate random attributes for this link
	RandomAttributes *AttributeParams `js:"randomAttributes"`
}

type OTelSemantics

type OTelSemantics string

OTelSemantics describes a specific set of OpenTelemetry semantic conventions.

const (
	SemanticsHTTP OTelSemantics = "http"
	SemanticsDB   OTelSemantics = "db"
)

type ParameterizedGenerator

type ParameterizedGenerator struct {
	// contains filtered or unexported fields
}

func NewParameterizedGenerator

func NewParameterizedGenerator(traceParams []*TraceParams) *ParameterizedGenerator

func (*ParameterizedGenerator) Traces

func (g *ParameterizedGenerator) Traces() ptrace.Traces

type Range

type Range struct {
	Min int64
	Max int64
}

Range represents and interval with the given upper and lower bound [Max, Min)

type SpanDefaults

type SpanDefaults struct {
	// AttributeSemantics whether to create attributes that follow specific OpenTelemetry semantics.
	AttributeSemantics *OTelSemantics `js:"attributeSemantics"`
	// Attributes that are added to each span.
	Attributes map[string]interface{} `js:"attributes"`
	// RandomAttributes random attributes generated for each span.
	RandomAttributes *AttributeParams `js:"randomAttributes"`
	// Random events generated for each span
	RandomEvents EventParams `js:"randomEvents"`
	// Random links generated for each span
	RandomLinks LinkParams `js:"randomLinks"`
}

SpanDefaults contains template parameters that are applied to all generated spans.

type SpanParams

type SpanParams struct {
	Count      int                    `json:"count"`
	Size       int                    `json:"size"`
	RandomName bool                   `json:"random_name"`
	FixedAttrs map[string]interface{} `json:"fixed_attrs"`
}

type SpanTemplate

type SpanTemplate struct {
	// Service is used to set the service.name attribute of the corresponding resource span.
	Service string `js:"service"`
	// Name represents the name of the span. If empty, the name will be randomly generated.
	Name *string `js:"name"`
	// ParentIDX defines the index of the parent span in TraceTemplate.Spans. ParentIDX must be smaller than the
	// own index. If empty, the parent is the span with the position directly before this span in TraceTemplate.Spans.
	ParentIDX *int `js:"parentIdx"`
	// Duration defines the interval for the generated span duration. If missing, a random duration is generated that
	// is shorter than the duration of the parent span.
	Duration *Range `js:"duration"`
	// AttributeSemantics can be set in order to generate attributes that follow a certain OpenTelemetry semantic
	// convention. So far only semantic convention for HTTP requests is supported.
	AttributeSemantics *OTelSemantics `js:"attributeSemantics"`
	// Attributes that are added to this span.
	Attributes map[string]interface{} `js:"attributes"`
	// RandomAttributes parameters to configure the creation of random attributes. If missing, no random attributes
	// are added to the span.
	RandomAttributes *AttributeParams `js:"randomAttributes"`
	// List of events for the span with specific parameters
	Events []Event `js:"events"`
	// List of links for the span with specific parameters
	Links []Link `js:"links"`
	// Generate random events for the span
	RandomEvents EventParams `js:"randomEvents"`
	// Generate random links for the span
	RandomLinks LinkParams `js:"randomLinks"`
}

SpanTemplate parameters that define how a span is created.

type TemplatedGenerator

type TemplatedGenerator struct {
	// contains filtered or unexported fields
}

TemplatedGenerator a trace generator that creates randomized traces based on a given TraceTemplate. The generator interprets the template parameters such that realistically looking traces with consistent spans and attributes are generated.

func NewTemplatedGenerator

func NewTemplatedGenerator(template *TraceTemplate) (*TemplatedGenerator, error)

NewTemplatedGenerator creates a new trace generator.

func (*TemplatedGenerator) Traces

func (g *TemplatedGenerator) Traces() ptrace.Traces

Traces implements Generator for TemplatedGenerator

type TraceParams

type TraceParams struct {
	ID                string     `json:"id"`
	RandomServiceName bool       `json:"random_service_name"`
	Spans             SpanParams `json:"spans"`
}

type TraceTemplate

type TraceTemplate struct {
	// Defaults parameters that are applied to each generated span.
	Defaults SpanDefaults `js:"defaults"`
	// Spans parameters for the individual spans of a trace.
	Spans []SpanTemplate `js:"spans"`
}

TraceTemplate describes how all a trace and it's spans are generated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL