tracing

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.

Index

Constants

View Source
const (
	// W3CPropagatorName is the name of the W3C trace context propagator
	W3CPropagatorName = "w3c"

	// W3CHeaderName is the name of the W3C trace context header
	W3CHeaderName = "traceparent"

	// W3CVersion is the version of the supported W3C trace context header.
	// The current specification assumes the version is set to 00.
	W3CVersion = "00"

	// W3CUnsampledTraceFlag is the trace-flag value for an unsampled trace.
	W3CUnsampledTraceFlag = "00"

	// W3CSampledTraceFlag is the trace-flag value for a sampled trace.
	W3CSampledTraceFlag = "01"
)
View Source
const (
	// JaegerPropagatorName is the name of the Jaeger trace context propagator
	JaegerPropagatorName = "jaeger"

	// JaegerHeaderName is the name of the Jaeger trace context header
	JaegerHeaderName = "uber-trace-id"

	// JaegerRootSpanID is the universal span ID of the root span.
	// Its value is zero, which is described in the Jaeger documentation as:
	// "0 value is valid and means “root span” (when not ignored)"
	JaegerRootSpanID = "0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a HTTP Client instrumenting the requests it performs with tracing information.

func NewClient

func NewClient(vu modules.VU, opts options) (*Client, error)

NewClient instantiates a new tracing Client

func (*Client) AsyncRequest

func (c *Client) AsyncRequest(method string, url goja.Value, args ...goja.Value) (*goja.Promise, error)

AsyncRequest instruments the http module's asyncRequest function with tracing headers, and ensures the trace_id is emitted as part of the output's data points metadata.

func (*Client) Configure

func (c *Client) Configure(opts options) error

Configure configures the tracing client with the given options.

func (*Client) Del

func (c *Client) Del(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Del instruments the http module's delete method.

func (*Client) Get

func (c *Client) Get(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Get instruments the http module's get method.

func (*Client) Head

func (c *Client) Head(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Head instruments the http module's head method.

func (*Client) Options

func (c *Client) Options(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Options instruments the http module's options method.

func (*Client) Patch

func (c *Client) Patch(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Patch instruments the http module's patch method.

func (*Client) Post

func (c *Client) Post(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Post instruments the http module's post method.

func (*Client) Put

func (c *Client) Put(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Put instruments the http module's put method.

func (*Client) Request

func (c *Client) Request(method string, url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

Request instruments the http module's request function with tracing headers, and ensures the trace_id is emitted as part of the output's data points metadata.

type HTTPAsyncRequestFunc

type HTTPAsyncRequestFunc func(method string, url goja.Value, args ...goja.Value) (*goja.Promise, error)

HTTPRequestFunc is a type alias representing the prototype of k6's http module's request function

type HTTPRequestFunc

type HTTPRequestFunc func(method string, url goja.Value, args ...goja.Value) (*httpmodule.Response, error)

HTTPRequestFunc is a type alias representing the prototype of k6's http module's request function

type JaegerPropagator

type JaegerPropagator struct{}

JaegerPropagator is a Propagator for the Jaeger trace context header

func (*JaegerPropagator) Propagate

func (p *JaegerPropagator) Propagate(traceID string) (http.Header, error)

Propagate returns a header with a random trace ID in the Jaeger format

type ModuleInstance

type ModuleInstance struct {

	// Client holds the module's default tracing client.
	*Client
	// contains filtered or unexported fields
}

ModuleInstance represents an instance of the JS module.

func (*ModuleInstance) Exports

func (mi *ModuleInstance) Exports() modules.Exports

Exports implements the modules.Instance interface and returns the exports of the JS module.

type Propagator

type Propagator interface {
	Propagate(traceID string) (http.Header, error)
}

Propagator is an interface for trace context propagation

type RootModule

type RootModule struct{}

RootModule is the global module instance that will create Client instances for each VU.

func New

func New() *RootModule

New returns a pointer to a new RootModule instance

func (*RootModule) NewModuleInstance

func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance

NewModuleInstance implements the modules.Module interface and returns a new instance for each VU.

type TraceID

type TraceID struct {
	// Prefix is the first 2 bytes of the trace-id, and is used to identify the
	// vendor of the trace-id.
	Prefix int16

	// Code is the third byte of the trace-id, and is used to identify the
	// vendor's specific trace-id format.
	Code int8

	// Time is the time at which the trace-id was generated.
	//
	// The time component is used as a source of randomness, and to ensure
	// uniqueness of the trace-id.
	//
	// When encoded, it should be in a format occupying the last 8 bytes of
	// the trace-id, and should ideally be encoded as nanoseconds.
	Time time.Time
}

TraceID represents a trace-id as defined by the W3c specification, and used by w3c, b3 and jaeger propagators. See Considerations for trace-id field generation for more information.

func (TraceID) Encode

func (t TraceID) Encode() (string, error)

Encode encodes the TraceID into a hex string.

The trace id is first encoded as a 16 bytes sequence, as follows: 1. Up to 2 bytes are encoded as the Prefix 2. The third byte is the Code. 3. Up to the following 8 bytes are UnixTimestampNano. 4. The remaining bytes are filled with random bytes.

The resulting 16 bytes sequence is then encoded as a hex string.

type W3CPropagator

type W3CPropagator struct{}

W3CPropagator is a Propagator for the W3C trace context header

func (*W3CPropagator) Propagate

func (p *W3CPropagator) Propagate(traceID string) (http.Header, error)

Propagate returns a header with a random trace ID in the W3C format

Jump to

Keyboard shortcuts

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