Documentation ¶
Overview ¶
Package jaeger provides a monkit plugin for sending traces to Jaeger Agent.
Example usage ¶
Your main method gets set up something like this:
package main import ( "net/http" jaeger "storj.io/monkit-jaeger" "github.com/spacemonkeygo/monkit/v3" "github.com/spacemonkeygo/monkit/v3/environment" "github.com/spacemonkeygo/monkit/v3/present" ) func main() { environment.Register(monkit.Default) collector, err := jaeger.NewThriftCollector("zipkin.whatever:9042", 200, "service name", []jaeger.Tag{ jaeger.Tag{ .... } }) if err != nil { panic(err) } jaeger.RegisterJaeger(monkit.Default, collector, jaeger.Options{ Fraction: 1}) ... }
Index ¶
- func NewJaegerTags(tags []Tag) []*jaeger.Tag
- func RegisterJaeger(reg *monkit.Registry, collector TraceCollector, opts Options) func()
- func RemoteTraceHandler(remoteInfo map[string]string) (trace *monkit.Trace, parentID int64)
- type HTTPTransport
- type Options
- type Tag
- type ThriftCollector
- type TraceCollector
- type Transport
- type UDPTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJaegerTags ¶
NewJaegerTags converts Tag into jaeger format.
func RegisterJaeger ¶
func RegisterJaeger(reg *monkit.Registry, collector TraceCollector, opts Options) func()
RegisterJaeger configures the given Registry reg to send the Spans from some portion of all new Traces to the given TraceCollector. it returns the unregister function.
func RemoteTraceHandler ¶
RemoteTraceHandler returns a new trace and its root span id based on remote trace information.
Types ¶
type HTTPTransport ¶
type HTTPTransport struct {
// contains filtered or unexported fields
}
HTTPTransport sends Jaeger spans via HTTP.
func OpenHTTPTransport ¶
func OpenHTTPTransport(ctx context.Context, log *zap.Logger, agentAddr string) (*HTTPTransport, error)
OpenHTTPTransport creates a new HTTP transport.
type Options ¶
type Options struct { Fraction float64 // The Fraction of traces to observe. Excluded func(*monkit.Span) bool // contains filtered or unexported fields }
Options represents the configuration for the register.
type Tag ¶
type Tag struct { Key string Value interface{} }
Tag is a key/value pair that allows us to translate monkit annotations and arguments into jaeger thrift tags.
type ThriftCollector ¶
type ThriftCollector struct {
// contains filtered or unexported fields
}
ThriftCollector matches the TraceCollector interface, but sends serialized jaeger.Span objects with the help of the registered transport, instead of the Scribe protocol. See RedirectPackets for the UDP server-side code.
func NewThriftCollector ¶
func NewThriftCollector(log *zap.Logger, agentAddr string, serviceName string, tags []Tag, packetSize, queueSize int, flushInterval time.Duration) ( *ThriftCollector, error)
NewThriftCollector creates a UDPCollector that sends packets to jaeger agent.
func NewUDPCollector ¶
func NewUDPCollector(log *zap.Logger, agentAddr string, serviceName string, tags []Tag, packetSize, queueSize int, flushInterval time.Duration) (*ThriftCollector, error)
NewUDPCollector creates a UDPCollector that sends packets to jaeger agent, unless (!) you use different protocol in agentAddr. Deprecated: use NewThriftCollector instead. This exists only for compatibility reasons.
func (*ThriftCollector) Close ¶
func (c *ThriftCollector) Close() error
Close gracefully shutdown the underlying udp connection, after remaining messages are sent out. Deprecated: cancelling the context of run will close the connection.
func (*ThriftCollector) Collect ¶
func (c *ThriftCollector) Collect(span *jaeger.Span)
Collect takes a jaeger.Span object, serializes it, and sends it to the configured collector_addr.
func (*ThriftCollector) Len ¶
func (c *ThriftCollector) Len() int
Len returns the amount of spans in the queue currently. This is only exposed for testing purpose.
func (*ThriftCollector) Run ¶
func (c *ThriftCollector) Run(ctx context.Context)
Run reads spans off the queue and appends them to the buffer. When the buffer fills up, it flushes. It also flushes on a jittered interval.
type TraceCollector ¶
type TraceCollector interface { // Collect gets called with a Span whenever a Span is completed on a // SpanManager. Collect(span *jaeger.Span) }
TraceCollector is an interface dealing with completed Spans on a SpanManager. See RegisterZipkin.
type Transport ¶
type Transport interface { // Send sends out the Jaeger spans. Send(ctx context.Context, batch *jaeger.Batch) error // Close closes the transport. Close() }
Transport defines how the span batches are sent.
type UDPTransport ¶
type UDPTransport struct {
// contains filtered or unexported fields
}
UDPTransport sends jaeger batches via UDP.
func OpenUDPTransport ¶
func OpenUDPTransport(ctx context.Context, log *zap.Logger, agentAddr string, maxPacketSize int) (*UDPTransport, error)
OpenUDPTransport creates new transport to send Jaeger batches via UDP.