trace

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// TraceName represents the tracing name.
	TraceName = "opentelemetry"
)

Variables

This section is empty.

Functions

func ExtractSpanId

func ExtractSpanId(ctx context.Context) string

ExtractSpanId returns the current Span's SpanID.

func ExtractTraceId

func ExtractTraceId(ctx context.Context) string

ExtractTraceId returns the current Span's TraceID.

func MetadataFromContext

func MetadataFromContext(ctx context.Context) (md metadata.Metadata)

MetadataFromContext Extracting contextual meta-information.

func StartSpanFromMetadata

func StartSpanFromMetadata(ctx context.Context, spanName string, md metadata.Metadata, opts ...trace.SpanStartOption) context.Context

StartSpanFromMetadata creates a new context with incoming md attached. takes all values from the given ctx, without deadline and error control.

Types

type Config

type Config struct {
	Endpoint   string
	Sampler    float64
	Batcher    string
	Attributes []attribute.KeyValue
}

A Config is a opentelemetry config.

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAttributes

func WithAttributes(attributes ...attribute.KeyValue) Option

WithAttributes adds attributes to the configured Resource.

func WithBatcher

func WithBatcher(batcher string) Option

func WithEndpoint

func WithEndpoint(endpoint string) Option

func WithName

func WithName(name string) Option

func WithSampler

func WithSampler(sampler float64) Option

type OptionFunc

type OptionFunc func(*Config)

type Tracer

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

func NewTracer

func NewTracer(kind trace.SpanKind, opts ...TracerOption) *Tracer

NewTracer create tracer instance

func (*Tracer) Extract

func (t *Tracer) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context

Extract reads cross-cutting concerns from the carrier into a Context.

func (*Tracer) Inject

func (t *Tracer) Inject(ctx context.Context, carrier propagation.TextMapCarrier)

Inject set cross-cutting concerns from the Context into the carrier.

func (*Tracer) Start

func (t *Tracer) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Start tracing span.

type TracerOption

type TracerOption func(*tracerOptions)

TracerOption is tracing option.

func WithPropagator

func WithPropagator(propagator propagation.TextMapPropagator) TracerOption

WithPropagator with tracer propagator.

type Tracing

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

func New

func New(opts ...Option) (*Tracing, error)

func (*Tracing) Shutdown

func (t *Tracing) Shutdown(ctx context.Context) error

Shutdown shuts down the span processors in the order they were registered.

Jump to

Keyboard shortcuts

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