jaeger

package module
v0.0.0-...-52b0792 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 24 Imported by: 6

README

monkit-jaeger

A plugin for http://github.com/spacemonkeygo/monkit that supports Jaeger.

development

Thrift helpers are generated with:

thrift -r --gen 'go:package_prefix=storj.io/monkit-jaeger/gen-go/' agent.thrift

License

Copyright (C) 2020 Storj Labs, Inc. Copyright (C) 2016 Space Monkey, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJaegerTags

func NewJaegerTags(tags []Tag) []*jaeger.Tag

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

func RemoteTraceHandler(remoteInfo map[string]string) (trace *monkit.Trace, parentID int64)

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.

func (*HTTPTransport) Close

func (u *HTTPTransport) Close()

Close closes the transport.

func (*HTTPTransport) Send

func (u *HTTPTransport) Send(ctx context.Context, batch *jaeger.Batch) error

Send sends out the Jaeger spans.

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.

func NewErrorTag

func NewErrorTag() Tag

NewErrorTag creates a new jaeger error tag.

func (*Tag) BuildJaegerThrift

func (t *Tag) BuildJaegerThrift() (*jaeger.Tag, error)

BuildJaegerThrift converts tag into jaeger thrift format.

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.

func (*ThriftCollector) Send

func (c *ThriftCollector) Send(ctx context.Context, transport Transport) (err error)

Send sends traces to jaeger agent.

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.

func (*UDPTransport) Close

func (u *UDPTransport) Close()

Close closes the transport.

func (*UDPTransport) Send

func (u *UDPTransport) Send(ctx context.Context, batch *jaeger.Batch) error

Send sends out the Jaeger spans.

Directories

Path Synopsis
gen-go
receiver module

Jump to

Keyboard shortcuts

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