tracing

package
v0.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attribute

func Attribute(key string, value interface{}) attribute.KeyValue

Attribute returns an attribute with the given key and value.

func Start

func Start(options ...Option) error

Start tracing.

func Stop

func Stop()

Stop tracing.

Types

type KeyValue

type KeyValue = attribute.KeyValue

KeyValue is an alias for the opentelemetry KeyValue attribute.

type Option

type Option func(*tracing) error

Option represents an option which can be applied to tracing.

func WithCollectorEndpoint

func WithCollectorEndpoint(endpoint string) Option

WithCollectorEndpoint sets the given collector endpoint.

func WithIdentity

func WithIdentity(attributes ...KeyValue) Option

WithIdentity sets extra tracing resource/identity attributes.

func WithSamplingRatio

func WithSamplingRatio(ratio float64) Option

WithSamplingRatio sets the given sampling ratio.

func WithServiceName

func WithServiceName(name string) Option

WithServiceName sets the service name reported for tracing.

type Span

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

Span is a (wrapped open-) tracing Span.

func SpanFromContext

func SpanFromContext(ctx context.Context) *Span

SpanFromContext returns the current Span from the context.

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...SpanStartOption) (context.Context, *Span)

StartSpan starts a new tracing Span. Must be ended with Span.End().

func (*Span) End

func (s *Span) End(opts ...SpanEndOption)

End the Span.

func (*Span) SetAttributes

func (s *Span) SetAttributes(attrs ...attribute.KeyValue)

SetAttributes sets attributes of the Span.

func (*Span) SetStatus

func (s *Span) SetStatus(err error)

SetStatus sets the status of the Span.

type SpanEndOption

type SpanEndOption func(*Span)

SpanEndOption is applied to a Span in Span.End.

func WithStatus

func WithStatus(err error) SpanEndOption

WithStatus sets the status for the span.

type SpanOptions

type SpanOptions struct {
	Options []trace.SpanStartOption
}

SpanOptions contains options for starting a Span.

type SpanStartOption

type SpanStartOption func(*SpanOptions)

SpanStartOption is applied to a Span in SpanStart.

func WithAttributeMap

func WithAttributeMap(attrMap map[string]interface{}) SpanStartOption

WithAttributeMap sets initial attributes of a Span from a map.

func WithAttributes

func WithAttributes(attrs ...attribute.KeyValue) SpanStartOption

WithAttributes sets initial attributes of a Span.

Jump to

Keyboard shortcuts

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