Documentation
¶
Index ¶
- type Collector
- func (c *Collector) Listen(ctx context.Context) error
- func (c *Collector) OnSpanComplete(fn func(traceID string, span Span))
- func (c *Collector) Serve(ctx context.Context) error
- func (c *Collector) SocketPath() string
- func (c *Collector) Start(ctx context.Context) error
- func (c *Collector) Traces() map[string][]Span
- type Event
- type EventType
- type Span
- type SpanKind
- type ViewClient
- type ViewServer
- func (s *ViewServer) Broadcast(span Span)
- func (s *ViewServer) Close() error
- func (s *ViewServer) ConnCount() int
- func (s *ViewServer) Listen(ctx context.Context) error
- func (s *ViewServer) Serve(ctx context.Context) error
- func (s *ViewServer) SocketPath() string
- func (s *ViewServer) Start(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector receives trace events over a Unix domain socket and assembles them into complete Span trees.
func NewCollector ¶
NewCollector creates a collector that listens on the given Unix socket path.
func (*Collector) Listen ¶
Listen creates the Unix domain socket. Call Serve afterwards to begin accepting connections.
func (*Collector) OnSpanComplete ¶
OnSpanComplete registers a callback invoked when a span is completed.
func (*Collector) Serve ¶
Serve accepts connections on the already-bound listener. It blocks until the context is cancelled or the listener is closed.
func (*Collector) SocketPath ¶
SocketPath returns the path of the Unix domain socket.
type Event ¶
type Event struct {
Type EventType `json:"type"`
SpanID string `json:"span_id"`
TraceID string `json:"trace_id"`
ParentID string `json:"parent_id,omitzero"`
Name string `json:"name"`
Kind SpanKind `json:"kind"`
Time time.Time `json:"time"`
Attrs map[string]string `json:"attrs,omitzero"`
}
Event is the unit of data sent from the instrumented application to the go-trace collector over a Unix domain socket.
func NewSpanEndEvent ¶
NewSpanEndEvent creates an event representing the end of a span.
type Span ¶
type Span struct {
ID string `json:"id"`
TraceID string `json:"trace_id"`
ParentID string `json:"parent_id,omitzero"`
Name string `json:"name"`
Kind SpanKind `json:"kind"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Attrs map[string]string `json:"attrs,omitzero"`
Children []Span `json:"children,omitzero"`
}
Span represents a single unit of work in a trace. Span is a value type; all mutation methods return a new copy.
func (Span) WithParentID ¶
WithParentID returns a new Span with the given parent ID.
type ViewClient ¶
type ViewClient struct {
// contains filtered or unexported fields
}
ViewClient connects to a ViewServer and receives completed spans.
func NewViewClient ¶
func NewViewClient(socketPath string) *ViewClient
NewViewClient creates a client that connects to the given socket path.
type ViewServer ¶
type ViewServer struct {
// contains filtered or unexported fields
}
ViewServer broadcasts completed spans to connected view clients over a Unix domain socket using JSON lines.
func NewViewServer ¶
func NewViewServer(socketPath string) *ViewServer
NewViewServer creates a view server that listens on the given socket path.
func (*ViewServer) Broadcast ¶
func (s *ViewServer) Broadcast(span Span)
Broadcast sends a completed span to all connected view clients. Connections that fail to receive are removed silently.
func (*ViewServer) Close ¶
func (s *ViewServer) Close() error
Close shuts down the server, closes all connections, and removes the socket file.
func (*ViewServer) ConnCount ¶
func (s *ViewServer) ConnCount() int
ConnCount returns the number of active client connections.
func (*ViewServer) Listen ¶
func (s *ViewServer) Listen(ctx context.Context) error
Listen creates the Unix domain socket. Call Serve afterwards to begin accepting connections. This split allows callers to detect listen errors synchronously before launching Serve in a goroutine.
func (*ViewServer) Serve ¶
func (s *ViewServer) Serve(ctx context.Context) error
Serve accepts connections on the already-bound listener. It blocks until the context is cancelled or the listener is closed.
func (*ViewServer) SocketPath ¶
func (s *ViewServer) SocketPath() string
SocketPath returns the path of the Unix domain socket.