dtrace

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ESClientFactory = newESClient

ESClientFactory is a factory to create ESClient

Functions

func HandleRequest

func HandleRequest(config *Config, r *http.Request, toProxy, toLoadBalancer chan *Span) (int, int, error)

HandleRequest parse json body and send it to elasticsearch channel

func Listen

func Listen(terminate chan os.Signal, config *Config, started chan bool)

Listen start listening address

func NormalizeURL

func NormalizeURL(raw string) string

NormalizeURL tries to parse raw url and replace hex sequenses with <hex>

func Proxy

func Proxy(proxyChannel, toLoadBalancer chan *Span, config *Config)

Proxy server distributes traces among all replicas

func SetLogger

func SetLogger(logger *logging.Logger)

SetLogger allows to set up external logger

Types

type Chain

type Chain struct {
	Path     string `json:"path"`
	Prefix   string `json:"prefix"`
	Level    int    `json:"level"`
	Duration int64  `json:"duration"`
}

Chain struct

type Config

type Config struct {
	Enable            bool     `yaml:"enable"`
	Address           string   `yaml:"address"`
	MaxActiveRequests int64    `yaml:"max_active_requests"`
	ElasticSearch     []string `yaml:"elasticsearch"`
	BulkSize          int      `yaml:"bulk_size"`
	Sampling          uint64   `yaml:"sampling"`
	Replicas          []string `yaml:"replicas"`
	MyReplicaIndex    int      `yaml:"my_replica_index"`
	MinTTL            int      `yaml:"min_ttl"`
	MaxTTL            int      `yaml:"max_ttl"`
}

Config settings

type Document

type Document struct {
	Fields map[string]interface{}
	Index  string
}

Document for elasticsearch

type ESBulkRequest

type ESBulkRequest interface {
	Index(name string) ESBulkRequest
	Type(name string) ESBulkRequest
	Doc(doc interface{}) ESBulkRequest
}

ESBulkRequest is the interface for elasticsearch bulk request

type ESBulkService

type ESBulkService interface {
	Add(ESBulkRequest) ESBulkService
	Do() (*elastic.BulkResponse, error)
}

ESBulkService is the interface for elasticsearch bulk service

type ESClient

type ESClient interface {
	Bulk() ESBulkService
	NewBulkIndexRequest() ESBulkRequest
}

ESClient is the interface for elasticsearch client

type HTTPClient

type HTTPClient interface {
	Send(*http.Request) error
}

HTTPClient is client to send proxy requests

var ProxyClient HTTPClient = &realHTTPClient{
	client: &http.Client{
		Timeout: time.Second * 5,
	},
}

ProxyClient implementing HTTPClient interface

type Span

type Span struct {
	System       string
	TraceID      string
	ProfileID    string
	ParentSpanID string
	ID           string `json:"spanid"`
	Annotations  SpanAnnotations
	Timeline     SpanTimeline
	Revision     int
	Prefix       string
	TraceHashSum uint64
	RawString    string
}

Span struct

func (*Span) CalculateTraceHashSum

func (span *Span) CalculateTraceHashSum()

CalculateTraceHashSum calculates hash sum for trace id

func (*Span) IsRoot

func (span *Span) IsRoot() bool

IsRoot returns true if span contains root annotation

type SpanAnnotations

type SpanAnnotations map[string]interface{}

SpanAnnotations is map[string]interface{}

type SpanMap

type SpanMap map[string]*Span

SpanMap is map[string]*Span

type SpanTimeline

type SpanTimeline map[string]SpanTimestamp

SpanTimeline is map[string]SpanTimestamp

type SpanTimestamp

type SpanTimestamp struct {
	Value time.Time
}

SpanTimestamp struct

func (*SpanTimestamp) UnmarshalJSON

func (st *SpanTimestamp) UnmarshalJSON(bytes []byte) (err error)

UnmarshalJSON implements json.Unmarshaler interface

type Trace

type Trace struct {
	ID        string
	Roots     SpanMap
	Children  map[string]SpanMap
	Spans     SpanMap
	Timestamp time.Time
	ProfileID string
	Root      *Span
	Completed bool
}

Trace struct

func (*Trace) GetChains

func (trace *Trace) GetChains(rootSpanID string) ([]*Span, []*Chain, error)

GetChains returns chain list of trace

func (*Trace) GetESDocuments

func (trace *Trace) GetESDocuments() []*Document

GetESDocuments returns document for elasticsearch

type TraceMap

type TraceMap map[string]*Trace

TraceMap is map[string]*Trace

func (TraceMap) Collect

func (traceMap TraceMap) Collect(minTTL, maxTTL time.Duration, toES chan *Document)

Collect completed traces and cleanout uncompleted

func (TraceMap) Put

func (traceMap TraceMap) Put(span *Span) *Trace

Put groups spans by trace ID

Jump to

Keyboard shortcuts

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