Documentation ¶
Overview ¶
Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.
Index ¶
- Constants
- type AlwaysOnSampler
- type Client
- func (c *Client) AsyncRequest(method string, url goja.Value, args ...goja.Value) (*goja.Promise, error)
- func (c *Client) Configure(opts options) error
- func (c *Client) Del(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Get(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Head(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Options(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Patch(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Post(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Put(url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- func (c *Client) Request(method string, url goja.Value, args ...goja.Value) (*httpmodule.Response, error)
- type HTTPAsyncRequestFunc
- type HTTPRequestFunc
- type JaegerPropagator
- type ModuleInstance
- type ProbabilisticSampler
- type Propagator
- type RootModule
- type Sampler
- type W3CPropagator
Constants ¶
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" )
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" // JaegerSampledTraceFlag is the trace-flag value for an unsampled trace. JaegerSampledTraceFlag = "0" // JaegerUnsampledTraceFlag is the trace-flag value for a sampled trace. JaegerUnsampledTraceFlag = "1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlwaysOnSampler ¶
type AlwaysOnSampler struct{}
AlwaysOnSampler implements the Sampler interface and allows to bypass sampling decisions by returning true for all Sampled() calls.
This is useful in cases where the user either does not provide the sampling option, or set it to 100% as it will avoid any call to the random number generator.
func NewAlwaysOnSampler ¶
func NewAlwaysOnSampler() *AlwaysOnSampler
NewAlwaysOnSampler returns a new AlwaysSampledSampler.
func (AlwaysOnSampler) ShouldSample ¶
func (AlwaysOnSampler) ShouldSample() bool
ShouldSample always returns true.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a HTTP Client instrumenting the requests it performs with tracing information.
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.
type HTTPAsyncRequestFunc ¶
type HTTPAsyncRequestFunc func(method string, url goja.Value, args ...goja.Value) (*goja.Promise, error)
HTTPAsyncRequestFunc is a type alias representing the prototype of k6's http module's asyncRequest 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 { // Sampler is used to determine whether or not a trace should be sampled. Sampler }
JaegerPropagator is a Propagator for the Jaeger trace context header
func NewJaegerPropagator ¶
func NewJaegerPropagator(s Sampler) *JaegerPropagator
NewJaegerPropagator returns a new JaegerPropagator with the given sampler.
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 ProbabilisticSampler ¶
type ProbabilisticSampler struct {
// contains filtered or unexported fields
}
ProbabilisticSampler implements the ProbabilisticSampler interface and allows to take probabilistic sampling decisions based on a sampling rate.
func NewProbabilisticSampler ¶
func NewProbabilisticSampler(samplingRate float64) *ProbabilisticSampler
NewProbabilisticSampler returns a new ProbablisticSampler with the provided sampling rate.
Note that the sampling rate is a percentage value within 0.0 <= samplingRate <= 1.0 bounds. If the provided sampling rate is outside of this range, it will be clamped to the closest bound.
func (ProbabilisticSampler) ShouldSample ¶
func (ps ProbabilisticSampler) ShouldSample() bool
ShouldSample returns true if the trace should be sampled.
Its return value is probabilistic, based on the selected sampling rate S, there is S percent chance that the returned value is true.
type Propagator ¶
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 (*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 Sampler ¶
type Sampler interface { // ShouldSample returns true if the trace should be sampled // false otherwise. ShouldSample() bool }
Sampler is an interface defining a sampling strategy.
type W3CPropagator ¶
type W3CPropagator struct { // Sampler is used to determine whether or not a trace should be sampled. Sampler }
W3CPropagator is a Propagator for the W3C trace context header
func NewW3CPropagator ¶
func NewW3CPropagator(s Sampler) *W3CPropagator
NewW3CPropagator returns a new W3CPropagator using the provided sampler to base its sampling decision upon.
Note that we allocate the propagator on the heap to ensure we conform to the Sampler interface, as the [Sampler.SetSamplingRate] method has a pointer receiver.