trace

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 7 Imported by: 7

Documentation

Overview

Package trace gives access to the global OpenTelemetry tracer configured internally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Span

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

Span is the individual component of a Trace. It represents a single named and timed operation of a workflow that is traced. A tracer is used to create a Span and it is then up to the operation the Span represents to properly end the Span when the operation itself ends.

func Start

func Start(ctx context.Context, kind SpanKind, name string) (context.Context, *Span)

Start creates a Span and a context containing the newly-created Span.

If the context provided contains a Span then the newly-created Span will be a child of that Span, otherwise it will be a root Span.

Any Span that is created must also be ended. This is the responsibility of the user. Implementations of this API may leak memory or other resources if Spans are not ended.

func (*Span) AddEvent

func (s *Span) AddEvent(name string)

AddEvent adds an event to the Span with the provided name.

func (*Span) Context

func (s *Span) Context() trace.SpanContext

Context returns the original OpenTelemetry span's context.

func (*Span) End

func (s *Span) End()

End sets the appropriate status and completes the Span. The Span is considered complete and ready to be delivered through the rest of the telemetry pipeline after this method is called. Therefore, updates to the Span are not allowed after this method has been called.

func (*Span) RecordError

func (s *Span) RecordError(msg string, err error)

RecordError will record the error as an exception span event for this Span.

func (*Span) SetBoolAttribute

func (s *Span) SetBoolAttribute(key string, value bool)

SetBoolAttribute sets a boolean attribute to the span.

func (*Span) SetFloatAttribute

func (s *Span) SetFloatAttribute(key string, value float64)

SetFloatAttribute sets a float attribute to the span.

func (*Span) SetIntAttribute

func (s *Span) SetIntAttribute(key string, value int64)

SetIntAttribute sets a integer attribute to the span.

func (*Span) SetSliceStringAttribute

func (s *Span) SetSliceStringAttribute(key string, values []string)

SetSliceStringAttribute sets a slice of string attributes to the span.

func (*Span) SetStringAttribute

func (s *Span) SetStringAttribute(key string, value string)

SetStringAttribute sets a string attribute to the span.

type SpanKind

type SpanKind int

SpanKind is the role a Span plays in a Trace.

const SpanKindClient SpanKind = 3

SpanKindClient is a SpanKind for a Span that represents the operation of client making a request to a server.

const SpanKindConsumer SpanKind = 5

SpanKindConsumer is a SpanKind for a Span that represents the operation of a consumer receiving a message from a message broker. Like SpanKindProducer Spans, there is often no direct relationship between this Span and the Span that produced the message.

const SpanKindInternal SpanKind = 1

SpanKindInternal is a SpanKind for a Span that represents an internal operation within an application.

const SpanKindProducer SpanKind = 4

SpanKindProducer is a SpanKind for a Span that represents the operation of a producer sending a message to a message broker. Unlike SpanKindClient and SpanKindServer, there is often no direct relationship between this kind of Span and a SpanKindConsumer kind. A SpanKindProducer Span will end once the message is accepted by the message broker which might not overlap with the processing of that message.

const SpanKindServer SpanKind = 2

SpanKindServer is a SpanKind for a Span that represents the operation of handling a request from a client.

Jump to

Keyboard shortcuts

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