tracing

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package tracing implements the tracing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchLimitsSpec

type BatchLimitsSpec struct {
	// MaxQueueSize is the maximum queue size to buffer spans for delayed processing. If the
	// queue gets full it drops the spans. Use BlockOnQueueFull to change this behavior.
	// The default value of MaxQueueSize is 2048.
	MaxQueueSize int `json:"maxQueueSize,omitempty" jsonschema:"default=2048"`

	// BatchTimeout is the maximum duration for constructing a batch. Processor
	// forcefully sends available spans when timeout is reached.
	// The default value of BatchTimeout is 5000 msec.
	BatchTimeout int64 `json:"batchTimeout,omitempty" jsonschema:"default=5000"`

	// ExportTimeout specifies the maximum duration for exporting spans. If the timeout
	// is reached, the export will be cancelled.
	// The default value of ExportTimeout is 30000 msec.
	ExportTimeout int64 `json:"exportTimeout,omitempty" jsonschema:"default=30000"`

	// MaxExportBatchSize is the maximum number of spans to process in a single batch.
	// If there are more than one batch worth of spans then it processes multiple batches
	// of spans one batch after the other without any delay.
	// The default value of MaxExportBatchSize is 512.
	MaxExportBatchSize int `json:"maxExportBatchSize,omitempty" jsonschema:"default=512"`
}

BatchLimitsSpec describes BatchSpanProcessorOptions.

type ExporterSpec

type ExporterSpec struct {
	Jaeger *JaegerSpec `json:"jaeger,omitempty"`
	Zipkin *ZipkinSpec `json:"zipkin,omitempty"`
	OTLP   *OTLPSpec   `json:"otlp,omitempty"`
}

ExporterSpec describes exporter.

func (*ExporterSpec) Validate

func (spec *ExporterSpec) Validate() error

Validate validates Spec.

type JaegerSpec

type JaegerSpec struct {
	Mode     jaegerMode `json:"mode" jsonschema:"required,enum=agent,enum=collector"`
	Endpoint string     `json:"endpoint,omitempty"`
	Username string     `json:"username,omitempty"`
	Password string     `json:"password,omitempty"`
}

JaegerSpec describes Jaeger.

func (*JaegerSpec) Validate

func (spec *JaegerSpec) Validate() error

Validate validates Spec.

type OTLPSpec

type OTLPSpec struct {
	Protocol    otlpProtocol `json:"protocol" jsonschema:"required,,enum=http,enum=grpc"`
	Endpoint    string       `json:"endpoint" jsonschema:"required"`
	Insecure    bool         `json:"insecure,omitempty"`
	Compression string       `json:"compression,omitempty" jsonschema:"enum=,enum=gzip"`
}

OTLPSpec describes OpenTelemetry exporter.

type Span

type Span struct {
	trace.Span
	// contains filtered or unexported fields
}

Span is the span of the Tracing.

var NoopSpan *Span

NoopSpan does nothing.

func (*Span) End

func (s *Span) End(options ...trace.SpanEndOption)

End completes the Span. Override trace.Span.End function.

func (*Span) InjectHTTP

func (s *Span) InjectHTTP(r *http.Request)

InjectHTTP injects span context into an HTTP request.

func (*Span) IsNoop

func (s *Span) IsNoop() bool

IsNoop returns whether the span is a noop span.

func (*Span) NewChild

func (s *Span) NewChild(name string) *Span

NewChild creates a new child span.

func (*Span) NewChildWithStart

func (s *Span) NewChildWithStart(name string, startAt time.Time) *Span

NewChildWithStart creates a new child span with specified start time.

func (*Span) Tracer

func (s *Span) Tracer() *Tracer

Tracer returns the tracer of the span.

type SpanLimitsSpec

type SpanLimitsSpec struct {
	// AttributeValueLengthLimit is the maximum allowed attribute value length.
	//
	// This limit only applies to string and string slice attribute values.
	// Any string longer than this value will be truncated to this length.
	//
	// Setting this to a negative value means no limit is applied.
	AttributeValueLengthLimit int `json:"attributeValueLengthLimit,omitempty" jsonschema:"default=-1"`

	// AttributeCountLimit is the maximum allowed span attribute count. Any
	// attribute added to a span once this limit is reached will be dropped.
	//
	// Setting this to zero means no attributes will be recorded.
	//
	// Setting this to a negative value means no limit is applied.
	AttributeCountLimit int `json:"attributeCountLimit,omitempty" jsonschema:"default=128"`

	// EventCountLimit is the maximum allowed span event count. Any event
	// added to a span once this limit is reached means it will be added but
	// the oldest event will be dropped.
	//
	// Setting this to zero means no events we be recorded.
	//
	// Setting this to a negative value means no limit is applied.
	EventCountLimit int `json:"eventCountLimit,omitempty" jsonschema:"default=128"`

	// LinkCountLimit is the maximum allowed span link count. Any link added
	// to a span once this limit is reached means it will be added but the
	// oldest link will be dropped.
	//
	// Setting this to zero means no links we be recorded.
	//
	// Setting this to a negative value means no limit is applied.
	LinkCountLimit int `json:"linkCountLimit,omitempty" jsonschema:"default=128"`

	// AttributePerEventCountLimit is the maximum number of attributes allowed
	// per span event. Any attribute added after this limit reached will be
	// dropped.
	//
	// Setting this to zero means no attributes will be recorded for events.
	//
	// Setting this to a negative value means no limit is applied.
	AttributePerEventCountLimit int `json:"attributePerEventCountLimit,omitempty" jsonschema:"default=128"`

	// AttributePerLinkCountLimit is the maximum number of attributes allowed
	// per span link. Any attribute added after this limit reached will be
	// dropped.
	//
	// Setting this to zero means no attributes will be recorded for links.
	//
	// Setting this to a negative value means no limit is applied.
	AttributePerLinkCountLimit int `json:"attributePerLinkCountLimit,omitempty" jsonschema:"default=128"`
}

SpanLimitsSpec represents the limits of a span.

type Spec

type Spec struct {
	ServiceName  string                `json:"serviceName" jsonschema:"required,minLength=1"`
	Tags         map[string]string     `json:"tags,omitempty"`
	Attributes   map[string]string     `json:"attributes,omitempty"`
	SpanLimits   *SpanLimitsSpec       `json:"spanLimits,omitempty"`
	SampleRate   float64               `json:"sampleRate,omitempty" jsonschema:"minimum=0,maximum=1,default=1"`
	BatchLimits  *BatchLimitsSpec      `json:"batchLimits,omitempty"`
	Exporter     *ExporterSpec         `json:"exporter,omitempty"`
	Zipkin       *ZipkinDeprecatedSpec `json:"zipkin,omitempty"`
	HeaderFormat headerFormat          `json:"headerFormat,omitempty" jsonschema:"default=trace-context,enum=trace-context,enum=b3"`
}

Spec describes Tracer.

func (*Spec) UnmarshalJSON

func (spec *Spec) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Spec) Validate

func (spec *Spec) Validate() error

Validate validates Spec.

type Tracer

type Tracer struct {
	trace.Tracer
	// contains filtered or unexported fields
}

Tracer is the tracer.

var NoopTracer *Tracer

NoopTracer is the tracer doing nothing.

func New

func New(spec *Spec) (*Tracer, error)

New creates a Tracing.

func (*Tracer) Close

func (t *Tracer) Close() error

Close trace.

func (*Tracer) IsNoopTracer

func (t *Tracer) IsNoopTracer() bool

IsNoopTracer checks whether tracer is noop tracer.

func (*Tracer) NewSpan

func (t *Tracer) NewSpan(ctx context.Context, name string) *Span

NewSpan creates a span.

func (*Tracer) NewSpanForHTTP

func (t *Tracer) NewSpanForHTTP(ctx context.Context, name string, req *http.Request) *Span

NewSpanForHTTP creates a span for http request.

type ZipkinDeprecatedSpec

type ZipkinDeprecatedSpec struct {
	Hostport      string  `json:"hostport,omitempty"`
	ServerURL     string  `json:"serverURL" jsonschema:"required,format=url"`
	DisableReport bool    `json:"disableReport,omitempty"`
	SampleRate    float64 `json:"sampleRate" jsonschema:"required,minimum=0,maximum=1"`
	SameSpan      bool    `json:"sameSpan,omitempty"`
	ID128Bit      bool    `json:"id128Bit,omitempty"`
}

ZipkinDeprecatedSpec describes Zipkin. Deprecated: This option will be kept until the next major version incremented release.

type ZipkinSpec

type ZipkinSpec struct {
	Endpoint string `json:"endpoint" jsonschema:"required,format=url"`
}

ZipkinSpec describes Zipkin.

Jump to

Keyboard shortcuts

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