tracing

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 137

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attribute added in v1.7.0

func Attribute(k string, v interface{}) attribute.KeyValue

Attribute takes a key value pair and returns attribute.KeyValue type.

func HTTPStatusCodeAttributes added in v1.7.0

func HTTPStatusCodeAttributes(code int) []attribute.KeyValue

HTTPStatusCodeAttributes generates attributes of the HTTP namespace as specified by the OpenTelemetry specification for a span.

func Name added in v1.7.0

func Name(names ...string) string

Name sets the span name by joining a list of strings in dot separated format.

Types

type LogrusHook

type LogrusHook struct{}

LogrusHook is a logrus hook which adds logrus events to active spans. If the span is not recording or the span context is invalid, the hook is a no-op.

func NewLogrusHook

func NewLogrusHook() *LogrusHook

NewLogrusHook creates a new logrus hook

func (*LogrusHook) Fire

func (h *LogrusHook) Fire(entry *logrus.Entry) error

Fire is called when a log event occurs.

func (*LogrusHook) Levels

func (h *LogrusHook) Levels() []logrus.Level

Levels returns the logrus levels that this hook is interested in.

type Span added in v1.7.0

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

Span is wrapper around otel trace.Span. Span is the individual component of a trace. It represents a single named and timed operation of a workflow that is traced.

func SpanFromContext added in v1.7.0

func SpanFromContext(ctx context.Context) *Span

SpanFromContext returns the current Span from the context.

func StartSpan

func StartSpan(ctx context.Context, opName string, opts ...SpanOpt) (context.Context, *Span)

StartSpan starts child span in a context.

func (*Span) AddEvent added in v1.7.0

func (s *Span) AddEvent(name string, options ...trace.EventOption)

AddEvent adds an event with provided name and options.

func (*Span) End added in v1.7.0

func (s *Span) End()

End completes the span.

func (*Span) SetAttributes added in v1.7.0

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

SetAttributes sets kv as attributes of the span.

func (*Span) SetStatus added in v1.7.0

func (s *Span) SetStatus(err error)

SetStatus sets the status of the current span. If an error is encountered, it records the error and sets span status to Error.

type SpanOpt added in v1.7.0

type SpanOpt func(config *StartConfig)

func WithHTTPRequest added in v1.7.0

func WithHTTPRequest(request *http.Request) SpanOpt

WithHTTPRequest marks span as a HTTP request operation from client to server. It'll append attributes from the HTTP request object and mark it with `SpanKindClient` type.

type StartConfig added in v1.7.0

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

StartConfig defines configuration for a new span object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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