Documentation ¶
Index ¶
- func To(e Exporter)
- func WithContextData(ctx context.Context, cd *ContextData) context.Context
- type ContextData
- type Decoder
- type EncodeDecoder
- type Encoder
- type EventData
- type Exporter
- type ID
- type IDGenerator
- type Span
- type SpanContext
- type SpanData
- type SpanID
- type SpanProcessor
- type SpannerContextKey
- type TraceID
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithContextData ¶
func WithContextData(ctx context.Context, cd *ContextData) context.Context
Types ¶
type ContextData ¶
func GetContextData ¶
func GetContextData(ctx context.Context) *ContextData
type EncodeDecoder ¶
EncodeDecoder is able to both encode and decode data
type EventData ¶
type EventData struct { Name string `json:"name"` Timestamp time.Time `json:"timestamp"` Attributes attr.Attrs `json:"attributes"` }
EventData describes the structure of an exported Span Event
func (EventData) MarshalJSON ¶
MarshalJSON encodes the EventData into a byte slice, returning it and an error
type Exporter ¶
type Exporter interface { // Export pushes the input SpanData `spans` to its output, as a non-blocking // function Export(ctx context.Context, spans []SpanData) error // Shutdown gracefully terminates the Exporter Shutdown(ctx context.Context) error }
Exporter is a module that pushes the span data to an output
type ID ¶
type ID interface { // IsValid returns whether the ID is a valid ID for its type IsValid() bool // String implements fmt.Stringer String() string }
ID interface describes the common actions an ID object should have
type IDGenerator ¶
type IDGenerator interface { // NewTraceID creates a new TraceID NewTraceID() TraceID // NewSpanID creates a new SpanID NewSpanID() SpanID }
IDGenerator is able to create TraceIDs and SpanIDs
type Span ¶
type Span interface { // Start sets the span to record Start() // End stops the span, returning the collected SpanData in the action End() // ID returns the SpanID of the Span ID() SpanID // IsRecording returns a boolean on whether the Span is currently recording IsRecording() bool // SetName overwrites the Span's name field with the string `name` SetName(name string) // SetParent overwrites the Span's parent_id field with the SpanID `id` SetParent(span Span) // Add appends attributes (key-value pairs) to the Span Add(attrs ...attr.Attr) // Attrs returns the Span's stored attributes Attrs() []attr.Attr // Replace will flush the Span's attributes and store the input attributes `attrs` in place Replace(attrs ...attr.Attr) // Event creates a new event within the Span Event(name string, attrs ...attr.Attr) // Extract returns the current SpanData for the Span, regardless of its status Extract() SpanData // Events returns the events in the Span Events() []EventData }
Span is a single action within a Trace, which holds metadata about the action's execution, as well as optional attributes and events
func Start ¶
Start reuses the Trace in the input context `ctx`, or creates one if it doesn't exist. It also creates the Span for the action, with string name `name`. Each call creates a new Span.
After calling Start, the input context will still reference the parent Span's ID, nil if it's a new Trace. The returned context will reference the returned Span's ID, to be used as the next call's parent.
The returned Span is required, even if to defer its closure, with `defer s.End()`. The caller MUST close the returned Span.
type SpanContext ¶
type SpanData ¶
type SpanData struct { TraceID TraceID SpanID SpanID ParentID *SpanID Name string StartTime time.Time EndTime *time.Time Attributes attr.Attrs Events []EventData }
SpanData is the output data that was recorded by a Span
It contains all the details stored in the Span, and it is returned with the `Extract()` method
func (SpanData) MarshalJSON ¶
MarshalJSON encodes the SpanData into a byte slice, returning it and an error
type SpanID ¶
type SpanID [8]byte
SpanID is a unique identifier for a span, or, a unique identifier for a single action across a request-response, sharing the same TraceID with other spans across the same transaction
type SpanProcessor ¶
type SpanProcessor interface { // Handle routes the input Span `span` to the SpanProcessor's Exporter Handle(span Span) // Shutdown gracefully stops the SpanProcessor, returning an error Shutdown(ctx context.Context) error // Flush will force-push the existing SpanData in the SpanProcessor's batch into the // Exporter, even if not yet scheduled to do so Flush(ctx context.Context) error }
SpanProcessor will handle routing ended Spans to an Exporter
func NewProcessor ¶
func NewProcessor(e Exporter) SpanProcessor
NewProcessor creates a new SpanProcessor configured with the input Exporter `e`
func Processor ¶
func Processor() SpanProcessor
type SpannerContextKey ¶
type SpannerContextKey string
SpannerContextKey is a unique type to use as key when storing traces in context
var ContextKey SpannerContextKey = "spanner"
ContextKey is the package's default context key for storing ContextData in context
type TraceID ¶
type TraceID [16]byte
TraceID is a unique identifier for the trace, or, a unique identifier for a set of actions across a request-response
type Tracer ¶
type Tracer interface { // Start reuses the Trace in the input context `ctx`, or creates one if it doesn't exist. It also // creates the Span for the action, with string name `name`. Each call creates a new Span. // // After calling Start, the input context will still reference the parent Span's ID, nil if it's a new Trace. // The returned context will reference the returned Span's ID, to be used as the next call's parent. // // The returned Span is required, even if to defer its closure, with `defer s.End()`. The caller MUST close the // returned Span. Start(ctx context.Context, name string) (context.Context, Span) // To sets the Span exporter to Exporter `e` To(e Exporter) // Processor returns the configured SpanProcessor in the Tracer Processor() SpanProcessor }
Tracer is responsible of creating new Traces and Spans, but it also allows to define the Exporter it should use