Documentation
¶
Index ¶
- func AddSpanAttribute(span *Span, key, value string)
- func AddSpanEvent(span *Span, name string, attributes map[string]string)
- func EndSpan(span *Span)
- func InitTracer(serviceName string)
- func SetSpanError(span *Span, err error)
- type Exporter
- type InMemoryExporter
- type NoOpExporter
- type Span
- type SpanEvent
- type SpanID
- type SpanKind
- type SpanStatus
- type TraceID
- type Tracer
- func (t *Tracer) AddSpanAttribute(span *Span, key, value string)
- func (t *Tracer) AddSpanEvent(span *Span, name string, attributes map[string]string)
- func (t *Tracer) EndSpan(span *Span)
- func (t *Tracer) GetTrace(traceID TraceID) []*Span
- func (t *Tracer) SetExporter(exporter Exporter)
- func (t *Tracer) SetSpanError(span *Span, err error)
- func (t *Tracer) StartSpan(ctx context.Context, name string, kind SpanKind) (*Span, context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSpanAttribute ¶
AddSpanAttribute adds attribute using global tracer
func AddSpanEvent ¶
AddSpanEvent adds event using global tracer
func SetSpanError ¶
SetSpanError sets span error using global tracer
Types ¶
type InMemoryExporter ¶
type InMemoryExporter struct {
// contains filtered or unexported fields
}
InMemoryExporter stores spans in memory for testing
func NewInMemoryExporter ¶
func NewInMemoryExporter() *InMemoryExporter
NewInMemoryExporter creates a new in-memory exporter
func (*InMemoryExporter) ExportSpan ¶
func (e *InMemoryExporter) ExportSpan(span *Span) error
ExportSpan stores span in memory
func (*InMemoryExporter) GetSpans ¶
func (e *InMemoryExporter) GetSpans() []*Span
GetSpans returns all stored spans
type NoOpExporter ¶
type NoOpExporter struct{}
NoOpExporter does nothing with spans
func (*NoOpExporter) ExportSpan ¶
func (e *NoOpExporter) ExportSpan(span *Span) error
ExportSpan implements Exporter interface
type Span ¶
type Span struct {
TraceID TraceID `json:"trace_id"`
SpanID SpanID `json:"span_id"`
ParentID SpanID `json:"parent_id,omitempty"`
Name string `json:"name"`
Kind SpanKind `json:"kind"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Duration time.Duration `json:"duration"`
Attributes map[string]string `json:"attributes,omitempty"`
Events []SpanEvent `json:"events,omitempty"`
Status SpanStatus `json:"status"`
Error string `json:"error,omitempty"`
}
Span represents a trace span
type SpanEvent ¶
type SpanEvent struct {
Timestamp time.Time `json:"timestamp"`
Name string `json:"name"`
Attributes map[string]string `json:"attributes,omitempty"`
}
SpanEvent represents an event within a span
type SpanKind ¶
type SpanKind string
SpanKind represents the kind of span
const ( // SpanKindClient indicates a client span SpanKindClient SpanKind = "client" // SpanKindServer indicates a server span SpanKindServer SpanKind = "server" // SpanKindInternal indicates an internal span SpanKindInternal SpanKind = "internal" // SpanKindProducer indicates a producer span SpanKindProducer SpanKind = "producer" // SpanKindConsumer indicates a consumer span SpanKindConsumer SpanKind = "consumer" )
type SpanStatus ¶
type SpanStatus string
SpanStatus represents span status
const ( // SpanStatusUnset indicates status is unset SpanStatusUnset SpanStatus = "unset" // SpanStatusOK indicates success SpanStatusOK SpanStatus = "ok" // SpanStatusError indicates an error SpanStatusError SpanStatus = "error" )
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer creates and manages spans
func (*Tracer) AddSpanAttribute ¶
AddSpanAttribute adds an attribute to span
func (*Tracer) AddSpanEvent ¶
AddSpanEvent adds an event to span
func (*Tracer) SetExporter ¶
SetExporter sets the span exporter
func (*Tracer) SetSpanError ¶
SetSpanError sets span error status