id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
13,400
stripe/veneur
worker.go
ImportMetric
func (w *Worker) ImportMetric(other samplers.JSONMetric) { w.mutex.Lock() defer w.mutex.Unlock() // we don't increment the processed metric counter here, it was already // counted by the original veneur that sent this to us w.imported++ if other.Type == counterTypeName || other.Type == gaugeTypeName { // this ...
go
func (w *Worker) ImportMetric(other samplers.JSONMetric) { w.mutex.Lock() defer w.mutex.Unlock() // we don't increment the processed metric counter here, it was already // counted by the original veneur that sent this to us w.imported++ if other.Type == counterTypeName || other.Type == gaugeTypeName { // this ...
[ "func", "(", "w", "*", "Worker", ")", "ImportMetric", "(", "other", "samplers", ".", "JSONMetric", ")", "{", "w", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "// we don't increment the processed...
// ImportMetric receives a metric from another veneur instance
[ "ImportMetric", "receives", "a", "metric", "from", "another", "veneur", "instance" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L336-L374
13,401
stripe/veneur
worker.go
ImportMetricGRPC
func (w *Worker) ImportMetricGRPC(other *metricpb.Metric) (err error) { w.mutex.Lock() defer w.mutex.Unlock() key := samplers.NewMetricKeyFromMetric(other) scope := samplers.ScopeFromPB(other.Scope) if other.Type == metricpb.Type_Counter || other.Type == metricpb.Type_Gauge { scope = samplers.GlobalOnly } i...
go
func (w *Worker) ImportMetricGRPC(other *metricpb.Metric) (err error) { w.mutex.Lock() defer w.mutex.Unlock() key := samplers.NewMetricKeyFromMetric(other) scope := samplers.ScopeFromPB(other.Scope) if other.Type == metricpb.Type_Counter || other.Type == metricpb.Type_Gauge { scope = samplers.GlobalOnly } i...
[ "func", "(", "w", "*", "Worker", ")", "ImportMetricGRPC", "(", "other", "*", "metricpb", ".", "Metric", ")", "(", "err", "error", ")", "{", "w", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mutex", ".", "Unlock", "(", ")", "\n\n...
// ImportMetricGRPC receives a metric from another veneur instance over gRPC. // // In practice, this is only called when in the aggregation tier, so we don't // handle LocalOnly scope.
[ "ImportMetricGRPC", "receives", "a", "metric", "from", "another", "veneur", "instance", "over", "gRPC", ".", "In", "practice", "this", "is", "only", "called", "when", "in", "the", "aggregation", "tier", "so", "we", "don", "t", "handle", "LocalOnly", "scope", ...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L380-L437
13,402
stripe/veneur
worker.go
Flush
func (w *Worker) Flush() WorkerMetrics { // This is a critical spot. The worker can't process metrics while this // mutex is held! So we try and minimize it by copying the maps of values // and assigning new ones. wm := NewWorkerMetrics() w.mutex.Lock() ret := w.wm processed := w.processed imported := w.importe...
go
func (w *Worker) Flush() WorkerMetrics { // This is a critical spot. The worker can't process metrics while this // mutex is held! So we try and minimize it by copying the maps of values // and assigning new ones. wm := NewWorkerMetrics() w.mutex.Lock() ret := w.wm processed := w.processed imported := w.importe...
[ "func", "(", "w", "*", "Worker", ")", "Flush", "(", ")", "WorkerMetrics", "{", "// This is a critical spot. The worker can't process metrics while this", "// mutex is held! So we try and minimize it by copying the maps of values", "// and assigning new ones.", "wm", ":=", "NewWorkerM...
// Flush resets the worker's internal metrics and returns their contents.
[ "Flush", "resets", "the", "worker", "s", "internal", "metrics", "and", "returns", "their", "contents", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L440-L459
13,403
stripe/veneur
worker.go
NewEventWorker
func NewEventWorker(cl *trace.Client, stats *statsd.Client) *EventWorker { return &EventWorker{ sampleChan: make(chan ssf.SSFSample), mutex: &sync.Mutex{}, traceClient: cl, stats: stats, } }
go
func NewEventWorker(cl *trace.Client, stats *statsd.Client) *EventWorker { return &EventWorker{ sampleChan: make(chan ssf.SSFSample), mutex: &sync.Mutex{}, traceClient: cl, stats: stats, } }
[ "func", "NewEventWorker", "(", "cl", "*", "trace", ".", "Client", ",", "stats", "*", "statsd", ".", "Client", ")", "*", "EventWorker", "{", "return", "&", "EventWorker", "{", "sampleChan", ":", "make", "(", "chan", "ssf", ".", "SSFSample", ")", ",", "m...
// NewEventWorker creates an EventWorker ready to collect events and service checks.
[ "NewEventWorker", "creates", "an", "EventWorker", "ready", "to", "collect", "events", "and", "service", "checks", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L478-L485
13,404
stripe/veneur
worker.go
Work
func (ew *EventWorker) Work() { for { select { case s := <-ew.sampleChan: ew.mutex.Lock() ew.samples = append(ew.samples, s) ew.mutex.Unlock() } } }
go
func (ew *EventWorker) Work() { for { select { case s := <-ew.sampleChan: ew.mutex.Lock() ew.samples = append(ew.samples, s) ew.mutex.Unlock() } } }
[ "func", "(", "ew", "*", "EventWorker", ")", "Work", "(", ")", "{", "for", "{", "select", "{", "case", "s", ":=", "<-", "ew", ".", "sampleChan", ":", "ew", ".", "mutex", ".", "Lock", "(", ")", "\n", "ew", ".", "samples", "=", "append", "(", "ew"...
// Work will start the EventWorker listening for events and service checks. // This function will never return.
[ "Work", "will", "start", "the", "EventWorker", "listening", "for", "events", "and", "service", "checks", ".", "This", "function", "will", "never", "return", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L489-L498
13,405
stripe/veneur
worker.go
Flush
func (ew *EventWorker) Flush() []ssf.SSFSample { ew.mutex.Lock() retsamples := ew.samples // these slices will be allocated again at append time ew.samples = nil ew.mutex.Unlock() if len(retsamples) != 0 { ew.stats.Count("worker.other_samples_flushed_total", int64(len(retsamples)), nil, 1.0) } return retsam...
go
func (ew *EventWorker) Flush() []ssf.SSFSample { ew.mutex.Lock() retsamples := ew.samples // these slices will be allocated again at append time ew.samples = nil ew.mutex.Unlock() if len(retsamples) != 0 { ew.stats.Count("worker.other_samples_flushed_total", int64(len(retsamples)), nil, 1.0) } return retsam...
[ "func", "(", "ew", "*", "EventWorker", ")", "Flush", "(", ")", "[", "]", "ssf", ".", "SSFSample", "{", "ew", ".", "mutex", ".", "Lock", "(", ")", "\n\n", "retsamples", ":=", "ew", ".", "samples", "\n", "// these slices will be allocated again at append time"...
// Flush returns the EventWorker's stored events and service checks and // resets the stored contents.
[ "Flush", "returns", "the", "EventWorker", "s", "stored", "events", "and", "service", "checks", "and", "resets", "the", "stored", "contents", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L502-L514
13,406
stripe/veneur
worker.go
NewSpanWorker
func NewSpanWorker(sinks []sinks.SpanSink, cl *trace.Client, statsd *statsd.Client, spanChan <-chan *ssf.SSFSpan, commonTags map[string]string) *SpanWorker { tags := make([]map[string]string, len(sinks)) for i, sink := range sinks { tags[i] = map[string]string{ "sink": sink.Name(), } } return &SpanWorker{ ...
go
func NewSpanWorker(sinks []sinks.SpanSink, cl *trace.Client, statsd *statsd.Client, spanChan <-chan *ssf.SSFSpan, commonTags map[string]string) *SpanWorker { tags := make([]map[string]string, len(sinks)) for i, sink := range sinks { tags[i] = map[string]string{ "sink": sink.Name(), } } return &SpanWorker{ ...
[ "func", "NewSpanWorker", "(", "sinks", "[", "]", "sinks", ".", "SpanSink", ",", "cl", "*", "trace", ".", "Client", ",", "statsd", "*", "statsd", ".", "Client", ",", "spanChan", "<-", "chan", "*", "ssf", ".", "SSFSpan", ",", "commonTags", "map", "[", ...
// NewSpanWorker creates a SpanWorker ready to collect events and service checks.
[ "NewSpanWorker", "creates", "a", "SpanWorker", "ready", "to", "collect", "events", "and", "service", "checks", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L532-L549
13,407
stripe/veneur
worker.go
Flush
func (tw *SpanWorker) Flush() { samples := &ssf.Samples{} // Flush and time each sink. for i, s := range tw.sinks { tags := make([]string, 0, len(tw.sinkTags[i])) for k, v := range tw.sinkTags[i] { tags = append(tags, fmt.Sprintf("%s:%s", k, v)) } sinkFlushStart := time.Now() s.Flush() tw.statsd.Timi...
go
func (tw *SpanWorker) Flush() { samples := &ssf.Samples{} // Flush and time each sink. for i, s := range tw.sinks { tags := make([]string, 0, len(tw.sinkTags[i])) for k, v := range tw.sinkTags[i] { tags = append(tags, fmt.Sprintf("%s:%s", k, v)) } sinkFlushStart := time.Now() s.Flush() tw.statsd.Timi...
[ "func", "(", "tw", "*", "SpanWorker", ")", "Flush", "(", ")", "{", "samples", ":=", "&", "ssf", ".", "Samples", "{", "}", "\n\n", "// Flush and time each sink.", "for", "i", ",", "s", ":=", "range", "tw", ".", "sinks", "{", "tags", ":=", "make", "(",...
// Flush invokes flush on each sink.
[ "Flush", "invokes", "flush", "on", "each", "sink", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/worker.go#L640-L661
13,408
stripe/veneur
config_parse.go
ReadProxyConfig
func ReadProxyConfig(path string) (c ProxyConfig, err error) { f, err := os.Open(path) if err != nil { return c, err } defer f.Close() c, err = readProxyConfig(f) c.applyDefaults() return }
go
func ReadProxyConfig(path string) (c ProxyConfig, err error) { f, err := os.Open(path) if err != nil { return c, err } defer f.Close() c, err = readProxyConfig(f) c.applyDefaults() return }
[ "func", "ReadProxyConfig", "(", "path", "string", ")", "(", "c", "ProxyConfig", ",", "err", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "c", ",", "err", "\n", "}", ...
// ReadProxyConfig unmarshals the proxy config file and slurps in its data.
[ "ReadProxyConfig", "unmarshals", "the", "proxy", "config", "file", "and", "slurps", "in", "its", "data", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/config_parse.go#L33-L42
13,409
stripe/veneur
config_parse.go
ParseInterval
func (c Config) ParseInterval() (time.Duration, error) { return time.ParseDuration(c.Interval) }
go
func (c Config) ParseInterval() (time.Duration, error) { return time.ParseDuration(c.Interval) }
[ "func", "(", "c", "Config", ")", "ParseInterval", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "return", "time", ".", "ParseDuration", "(", "c", ".", "Interval", ")", "\n", "}" ]
// ParseInterval handles parsing the flush interval as a time.Duration
[ "ParseInterval", "handles", "parsing", "the", "flush", "interval", "as", "a", "time", ".", "Duration" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/config_parse.go#L229-L231
13,410
stripe/veneur
proxy.go
RefreshDestinations
func (p *Proxy) RefreshDestinations(serviceName string, ring *consistent.Consistent, mtx *sync.Mutex) { samples := &ssf.Samples{} defer metrics.Report(p.TraceClient, samples) srvTags := map[string]string{"service": serviceName} start := time.Now() destinations, err := p.Discoverer.GetDestinationsForService(servic...
go
func (p *Proxy) RefreshDestinations(serviceName string, ring *consistent.Consistent, mtx *sync.Mutex) { samples := &ssf.Samples{} defer metrics.Report(p.TraceClient, samples) srvTags := map[string]string{"service": serviceName} start := time.Now() destinations, err := p.Discoverer.GetDestinationsForService(servic...
[ "func", "(", "p", "*", "Proxy", ")", "RefreshDestinations", "(", "serviceName", "string", ",", "ring", "*", "consistent", ".", "Consistent", ",", "mtx", "*", "sync", ".", "Mutex", ")", "{", "samples", ":=", "&", "ssf", ".", "Samples", "{", "}", "\n", ...
// RefreshDestinations updates the server's list of valid destinations // for flushing. This should be called periodically to ensure we have // the latest data.
[ "RefreshDestinations", "updates", "the", "server", "s", "list", "of", "valid", "destinations", "for", "flushing", ".", "This", "should", "be", "called", "periodically", "to", "ensure", "we", "have", "the", "latest", "data", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxy.go#L484-L514
13,411
stripe/veneur
proxy.go
ProxyMetrics
func (p *Proxy) ProxyMetrics(ctx context.Context, jsonMetrics []samplers.JSONMetric, origin string) { span, _ := trace.StartSpanFromContext(ctx, "veneur.opentracing.proxy.proxy_metrics") defer span.ClientFinish(p.TraceClient) if p.ForwardTimeout > 0 { var cancel func() ctx, cancel = context.WithTimeout(ctx, p.F...
go
func (p *Proxy) ProxyMetrics(ctx context.Context, jsonMetrics []samplers.JSONMetric, origin string) { span, _ := trace.StartSpanFromContext(ctx, "veneur.opentracing.proxy.proxy_metrics") defer span.ClientFinish(p.TraceClient) if p.ForwardTimeout > 0 { var cancel func() ctx, cancel = context.WithTimeout(ctx, p.F...
[ "func", "(", "p", "*", "Proxy", ")", "ProxyMetrics", "(", "ctx", "context", ".", "Context", ",", "jsonMetrics", "[", "]", "samplers", ".", "JSONMetric", ",", "origin", "string", ")", "{", "span", ",", "_", ":=", "trace", ".", "StartSpanFromContext", "(",...
// ProxyMetrics takes a slice of JSONMetrics and breaks them up into // multiple HTTP requests by MetricKey using the hash ring.
[ "ProxyMetrics", "takes", "a", "slice", "of", "JSONMetrics", "and", "breaks", "them", "up", "into", "multiple", "HTTP", "requests", "by", "MetricKey", "using", "the", "hash", "ring", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxy.go#L580-L621
13,412
stripe/veneur
http.go
ImportMetrics
func (s *Server) ImportMetrics(ctx context.Context, jsonMetrics []samplers.JSONMetric) { span, _ := trace.StartSpanFromContext(ctx, "veneur.opentracing.import.import_metrics") defer span.Finish() // we have a slice of json metrics that we need to divide up across the workers // we don't want to push one metric at ...
go
func (s *Server) ImportMetrics(ctx context.Context, jsonMetrics []samplers.JSONMetric) { span, _ := trace.StartSpanFromContext(ctx, "veneur.opentracing.import.import_metrics") defer span.Finish() // we have a slice of json metrics that we need to divide up across the workers // we don't want to push one metric at ...
[ "func", "(", "s", "*", "Server", ")", "ImportMetrics", "(", "ctx", "context", ".", "Context", ",", "jsonMetrics", "[", "]", "samplers", ".", "JSONMetric", ")", "{", "span", ",", "_", ":=", "trace", ".", "StartSpanFromContext", "(", "ctx", ",", "\"", "\...
// ImportMetrics feeds a slice of json metrics to the server's workers
[ "ImportMetrics", "feeds", "a", "slice", "of", "json", "metrics", "to", "the", "server", "s", "workers" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/http.go#L54-L71
13,413
stripe/veneur
http.go
newJSONMetricsByWorker
func newJSONMetricsByWorker(metrics []samplers.JSONMetric, numWorkers int) *jsonMetricsByWorker { ret := &jsonMetricsByWorker{ sjm: newSortableJSONMetrics(metrics, numWorkers), } sort.Sort(ret.sjm) return ret }
go
func newJSONMetricsByWorker(metrics []samplers.JSONMetric, numWorkers int) *jsonMetricsByWorker { ret := &jsonMetricsByWorker{ sjm: newSortableJSONMetrics(metrics, numWorkers), } sort.Sort(ret.sjm) return ret }
[ "func", "newJSONMetricsByWorker", "(", "metrics", "[", "]", "samplers", ".", "JSONMetric", ",", "numWorkers", "int", ")", "*", "jsonMetricsByWorker", "{", "ret", ":=", "&", "jsonMetricsByWorker", "{", "sjm", ":", "newSortableJSONMetrics", "(", "metrics", ",", "n...
// iterate over a sorted set of jsonmetrics, returning them in contiguous // nonempty chunks such that each chunk corresponds to a single worker.
[ "iterate", "over", "a", "sorted", "set", "of", "jsonmetrics", "returning", "them", "in", "contiguous", "nonempty", "chunks", "such", "that", "each", "chunk", "corresponds", "to", "a", "single", "worker", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/http.go#L115-L121
13,414
stripe/veneur
sinks/splunk/splunk.go
submitter
func (sss *splunkSpanSink) submitter(sync chan struct{}, ready chan struct{}) { ctx := context.Background() for { exit := sss.submitBatch(ctx, sync, ready) if exit { return } } }
go
func (sss *splunkSpanSink) submitter(sync chan struct{}, ready chan struct{}) { ctx := context.Background() for { exit := sss.submitBatch(ctx, sync, ready) if exit { return } } }
[ "func", "(", "sss", "*", "splunkSpanSink", ")", "submitter", "(", "sync", "chan", "struct", "{", "}", ",", "ready", "chan", "struct", "{", "}", ")", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "for", "{", "exit", ":=", "sss", "....
// submitter runs for the lifetime of the sink and performs batch-wise // submission to the HEC sink.
[ "submitter", "runs", "for", "the", "lifetime", "of", "the", "sink", "and", "performs", "batch", "-", "wise", "submission", "to", "the", "HEC", "sink", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/splunk/splunk.go#L182-L190
13,415
stripe/veneur
sinks/splunk/splunk.go
setupHTTPRequest
func (sss *splunkSpanSink) setupHTTPRequest(ctx context.Context) (context.CancelFunc, *hecRequest, io.Writer, error) { ctx, cancel := context.WithCancel(ctx) hecReq := sss.hec.newRequest() req, w, err := hecReq.Start(ctx) if err != nil { cancel() return nil, nil, nil, err } // At this point, we have a workab...
go
func (sss *splunkSpanSink) setupHTTPRequest(ctx context.Context) (context.CancelFunc, *hecRequest, io.Writer, error) { ctx, cancel := context.WithCancel(ctx) hecReq := sss.hec.newRequest() req, w, err := hecReq.Start(ctx) if err != nil { cancel() return nil, nil, nil, err } // At this point, we have a workab...
[ "func", "(", "sss", "*", "splunkSpanSink", ")", "setupHTTPRequest", "(", "ctx", "context", ".", "Context", ")", "(", "context", ".", "CancelFunc", ",", "*", "hecRequest", ",", "io", ".", "Writer", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "co...
// setupHTTPRequest sets up and kicks off an HTTP request. It returns // the elements of it that are necessary in sending a single batch to // the HEC.
[ "setupHTTPRequest", "sets", "up", "and", "kicks", "off", "an", "HTTP", "request", ".", "It", "returns", "the", "elements", "of", "it", "that", "are", "necessary", "in", "sending", "a", "single", "batch", "to", "the", "HEC", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/splunk/splunk.go#L206-L219
13,416
stripe/veneur
sinks/splunk/splunk.go
submitOneEvent
func (sss *splunkSpanSink) submitOneEvent(ctx context.Context, w io.Writer, ev *Event) error { if sss.sendTimeout > 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, sss.sendTimeout) defer cancel() } encodeErrors := make(chan error) enc := json.NewEncoder(w) go func() { err := enc.En...
go
func (sss *splunkSpanSink) submitOneEvent(ctx context.Context, w io.Writer, ev *Event) error { if sss.sendTimeout > 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, sss.sendTimeout) defer cancel() } encodeErrors := make(chan error) enc := json.NewEncoder(w) go func() { err := enc.En...
[ "func", "(", "sss", "*", "splunkSpanSink", ")", "submitOneEvent", "(", "ctx", "context", ".", "Context", ",", "w", "io", ".", "Writer", ",", "ev", "*", "Event", ")", "error", "{", "if", "sss", ".", "sendTimeout", ">", "0", "{", "var", "cancel", "cont...
// submitOneEvent takes one event and submits it to an HEC HTTP // connection. It observes the configured splunk_hec_ingest_timeout - // if the timeout is exceeded, it returns an error. If the timeout is // 0, it waits forever to submit the event.
[ "submitOneEvent", "takes", "one", "event", "and", "submits", "it", "to", "an", "HEC", "HTTP", "connection", ".", "It", "observes", "the", "configured", "splunk_hec_ingest_timeout", "-", "if", "the", "timeout", "is", "exceeded", "it", "returns", "an", "error", ...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/splunk/splunk.go#L292-L313
13,417
stripe/veneur
sinks/splunk/splunk.go
Flush
func (sss *splunkSpanSink) Flush() { // report the sink stats: samples := &ssf.Samples{} samples.Add( ssf.Count( sinks.MetricKeyTotalSpansFlushed, float32(atomic.SwapUint32(&sss.ingestedSpans, 0)), map[string]string{"sink": sss.Name()}), ssf.Count( sinks.MetricKeyTotalSpansDropped, float32(atomic....
go
func (sss *splunkSpanSink) Flush() { // report the sink stats: samples := &ssf.Samples{} samples.Add( ssf.Count( sinks.MetricKeyTotalSpansFlushed, float32(atomic.SwapUint32(&sss.ingestedSpans, 0)), map[string]string{"sink": sss.Name()}), ssf.Count( sinks.MetricKeyTotalSpansDropped, float32(atomic....
[ "func", "(", "sss", "*", "splunkSpanSink", ")", "Flush", "(", ")", "{", "// report the sink stats:", "samples", ":=", "&", "ssf", ".", "Samples", "{", "}", "\n", "samples", ".", "Add", "(", "ssf", ".", "Count", "(", "sinks", ".", "MetricKeyTotalSpansFlushe...
// Flush takes the batched-up events and sends them to the HEC // endpoint for ingestion. If set, it uses the send timeout configured // for the span batch.
[ "Flush", "takes", "the", "batched", "-", "up", "events", "and", "sends", "them", "to", "the", "HEC", "endpoint", "for", "ingestion", ".", "If", "set", "it", "uses", "the", "send", "timeout", "configured", "for", "the", "span", "batch", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/splunk/splunk.go#L407-L428
13,418
stripe/veneur
sinks/lightstep/lightstep.go
NewLightStepSpanSink
func NewLightStepSpanSink(collector string, reconnectPeriod string, maximumSpans int, numClients int, accessToken string, log *logrus.Logger) (*LightStepSpanSink, error) { var host *url.URL host, err := url.Parse(collector) if err != nil { log.WithError(err).WithField( "host", collector, ).Error("Error parsin...
go
func NewLightStepSpanSink(collector string, reconnectPeriod string, maximumSpans int, numClients int, accessToken string, log *logrus.Logger) (*LightStepSpanSink, error) { var host *url.URL host, err := url.Parse(collector) if err != nil { log.WithError(err).WithField( "host", collector, ).Error("Error parsin...
[ "func", "NewLightStepSpanSink", "(", "collector", "string", ",", "reconnectPeriod", "string", ",", "maximumSpans", "int", ",", "numClients", "int", ",", "accessToken", "string", ",", "log", "*", "logrus", ".", "Logger", ")", "(", "*", "LightStepSpanSink", ",", ...
// NewLightStepSpanSink creates a new instance of a LightStepSpanSink.
[ "NewLightStepSpanSink", "creates", "a", "new", "instance", "of", "a", "LightStepSpanSink", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/lightstep/lightstep.go#L42-L111
13,419
stripe/veneur
sinks/lightstep/lightstep.go
Ingest
func (ls *LightStepSpanSink) Ingest(ssfSpan *ssf.SSFSpan) error { if err := protocol.ValidateTrace(ssfSpan); err != nil { return err } parentID := ssfSpan.ParentId if parentID <= 0 { parentID = 0 } var errorCode int64 if ssfSpan.Error { errorCode = 1 } timestamp := time.Unix(ssfSpan.StartTimestamp/1e9...
go
func (ls *LightStepSpanSink) Ingest(ssfSpan *ssf.SSFSpan) error { if err := protocol.ValidateTrace(ssfSpan); err != nil { return err } parentID := ssfSpan.ParentId if parentID <= 0 { parentID = 0 } var errorCode int64 if ssfSpan.Error { errorCode = 1 } timestamp := time.Unix(ssfSpan.StartTimestamp/1e9...
[ "func", "(", "ls", "*", "LightStepSpanSink", ")", "Ingest", "(", "ssfSpan", "*", "ssf", ".", "SSFSpan", ")", "error", "{", "if", "err", ":=", "protocol", ".", "ValidateTrace", "(", "ssfSpan", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", ...
// Ingest takes in a span and passed it along to the LS client after // some sanity checks and improvements are made.
[ "Ingest", "takes", "in", "a", "span", "and", "passed", "it", "along", "to", "the", "LS", "client", "after", "some", "sanity", "checks", "and", "improvements", "are", "made", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/lightstep/lightstep.go#L126-L201
13,420
stripe/veneur
sinks/lightstep/lightstep.go
Flush
func (ls *LightStepSpanSink) Flush() { ls.mutex.Lock() defer ls.mutex.Unlock() samples := &ssf.Samples{} defer metrics.Report(ls.traceClient, samples) totalCount := int64(0) ls.serviceCount.Range(func(keyI, valueI interface{}) bool { service, ok := keyI.(string) if !ok { ls.log.WithFields(logrus.Fields{...
go
func (ls *LightStepSpanSink) Flush() { ls.mutex.Lock() defer ls.mutex.Unlock() samples := &ssf.Samples{} defer metrics.Report(ls.traceClient, samples) totalCount := int64(0) ls.serviceCount.Range(func(keyI, valueI interface{}) bool { service, ok := keyI.(string) if !ok { ls.log.WithFields(logrus.Fields{...
[ "func", "(", "ls", "*", "LightStepSpanSink", ")", "Flush", "(", ")", "{", "ls", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "ls", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "samples", ":=", "&", "ssf", ".", "Samples", "{", "}", "\n", ...
// Flush doesn't need to do anything to the LS tracer, so we emit metrics // instead.
[ "Flush", "doesn", "t", "need", "to", "do", "anything", "to", "the", "LS", "tracer", "so", "we", "emit", "metrics", "instead", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/lightstep/lightstep.go#L205-L242
13,421
stripe/veneur
consul.go
NewConsul
func NewConsul(config *api.Config) (*Consul, error) { consulClient, err := api.NewClient(config) if err != nil { return nil, err } return &Consul{ ConsulHealth: consulClient.Health(), }, nil }
go
func NewConsul(config *api.Config) (*Consul, error) { consulClient, err := api.NewClient(config) if err != nil { return nil, err } return &Consul{ ConsulHealth: consulClient.Health(), }, nil }
[ "func", "NewConsul", "(", "config", "*", "api", ".", "Config", ")", "(", "*", "Consul", ",", "error", ")", "{", "consulClient", ",", "err", ":=", "api", ".", "NewClient", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ","...
// NewConsul creates a new instance of a Consul Discoverer
[ "NewConsul", "creates", "a", "new", "instance", "of", "a", "Consul", "Discoverer" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/consul.go#L17-L26
13,422
stripe/veneur
sinks/ssfmetrics/metrics.go
sendMetrics
func (m *metricExtractionSink) sendMetrics(metrics []samplers.UDPMetric) { for _, metric := range metrics { m.workers[metric.Digest%uint32(len(m.workers))].IngestUDP(metric) } }
go
func (m *metricExtractionSink) sendMetrics(metrics []samplers.UDPMetric) { for _, metric := range metrics { m.workers[metric.Digest%uint32(len(m.workers))].IngestUDP(metric) } }
[ "func", "(", "m", "*", "metricExtractionSink", ")", "sendMetrics", "(", "metrics", "[", "]", "samplers", ".", "UDPMetric", ")", "{", "for", "_", ",", "metric", ":=", "range", "metrics", "{", "m", ".", "workers", "[", "metric", ".", "Digest", "%", "uint...
// sendMetrics enqueues the metrics into the worker channels
[ "sendMetrics", "enqueues", "the", "metrics", "into", "the", "worker", "channels" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/ssfmetrics/metrics.go#L65-L69
13,423
stripe/veneur
sinks/ssfmetrics/metrics.go
Ingest
func (m *metricExtractionSink) Ingest(span *ssf.SSFSpan) error { var metricsCount int defer func() { atomic.AddInt64(&m.metricsGenerated, int64(metricsCount)) atomic.AddInt64(&m.spansProcessed, 1) }() metrics, err := samplers.ConvertMetrics(span) if err != nil { if _, ok := err.(samplers.InvalidMetrics); ok ...
go
func (m *metricExtractionSink) Ingest(span *ssf.SSFSpan) error { var metricsCount int defer func() { atomic.AddInt64(&m.metricsGenerated, int64(metricsCount)) atomic.AddInt64(&m.spansProcessed, 1) }() metrics, err := samplers.ConvertMetrics(span) if err != nil { if _, ok := err.(samplers.InvalidMetrics); ok ...
[ "func", "(", "m", "*", "metricExtractionSink", ")", "Ingest", "(", "span", "*", "ssf", ".", "SSFSpan", ")", "error", "{", "var", "metricsCount", "int", "\n", "defer", "func", "(", ")", "{", "atomic", ".", "AddInt64", "(", "&", "m", ".", "metricsGenerat...
// Ingest extracts metrics from an SSF span, and feeds them into the // appropriate metric sinks.
[ "Ingest", "extracts", "metrics", "from", "an", "SSF", "span", "and", "feeds", "them", "into", "the", "appropriate", "metric", "sinks", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/ssfmetrics/metrics.go#L82-L138
13,424
stripe/veneur
socket.go
NewSocket
func NewSocket(addr *net.UDPAddr, recvBuf int, reuseport bool) (net.PacketConn, error) { if reuseport { panic("SO_REUSEPORT not supported on this platform") } serverConn, err := net.ListenUDP("udp", addr) if err != nil { return nil, err } if err := serverConn.SetReadBuffer(recvBuf); err != nil { return nil,...
go
func NewSocket(addr *net.UDPAddr, recvBuf int, reuseport bool) (net.PacketConn, error) { if reuseport { panic("SO_REUSEPORT not supported on this platform") } serverConn, err := net.ListenUDP("udp", addr) if err != nil { return nil, err } if err := serverConn.SetReadBuffer(recvBuf); err != nil { return nil,...
[ "func", "NewSocket", "(", "addr", "*", "net", ".", "UDPAddr", ",", "recvBuf", "int", ",", "reuseport", "bool", ")", "(", "net", ".", "PacketConn", ",", "error", ")", "{", "if", "reuseport", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "serv...
// NewSocket creates a socket which is intended for use by a single goroutine.
[ "NewSocket", "creates", "a", "socket", "which", "is", "intended", "for", "use", "by", "a", "single", "goroutine", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/socket.go#L10-L22
13,425
stripe/veneur
plugins/localfile/localfile.go
Flush
func (p *Plugin) Flush(ctx context.Context, metrics []samplers.InterMetric) error { f, err := os.OpenFile(p.FilePath, os.O_RDWR|os.O_APPEND|os.O_CREATE, os.ModePerm) defer f.Close() if err != nil { return fmt.Errorf("couldn't open %s for appending: %s", p.FilePath, err) } appendToWriter(f, metrics, p.hostname, ...
go
func (p *Plugin) Flush(ctx context.Context, metrics []samplers.InterMetric) error { f, err := os.OpenFile(p.FilePath, os.O_RDWR|os.O_APPEND|os.O_CREATE, os.ModePerm) defer f.Close() if err != nil { return fmt.Errorf("couldn't open %s for appending: %s", p.FilePath, err) } appendToWriter(f, metrics, p.hostname, ...
[ "func", "(", "p", "*", "Plugin", ")", "Flush", "(", "ctx", "context", ".", "Context", ",", "metrics", "[", "]", "samplers", ".", "InterMetric", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "p", ".", "FilePath", ",", "os", ...
// Flush the metrics from the LocalFilePlugin
[ "Flush", "the", "metrics", "from", "the", "LocalFilePlugin" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/plugins/localfile/localfile.go#L32-L41
13,426
stripe/veneur
protocol/errors.go
IsFramingError
func IsFramingError(err error) bool { switch err.(type) { case *errFrameVersion: return true case *errFramingIO: return true case *errFrameLength: return true } return false }
go
func IsFramingError(err error) bool { switch err.(type) { case *errFrameVersion: return true case *errFramingIO: return true case *errFrameLength: return true } return false }
[ "func", "IsFramingError", "(", "err", "error", ")", "bool", "{", "switch", "err", ".", "(", "type", ")", "{", "case", "*", "errFrameVersion", ":", "return", "true", "\n", "case", "*", "errFramingIO", ":", "return", "true", "\n", "case", "*", "errFrameLen...
// IsFramingError returns true if an error is a wire protocol framing // error. This indicates that the stream can no longer be used for // reading SSF data and should be closed.
[ "IsFramingError", "returns", "true", "if", "an", "error", "is", "a", "wire", "protocol", "framing", "error", ".", "This", "indicates", "that", "the", "stream", "can", "no", "longer", "be", "used", "for", "reading", "SSF", "data", "and", "should", "be", "cl...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/protocol/errors.go#L32-L42
13,427
stripe/veneur
ssf/samples.go
Add
func (s *Samples) Add(sample ...*SSFSample) { if s.Batch == nil { s.Batch = []*SSFSample{} } s.Batch = append(s.Batch, sample...) }
go
func (s *Samples) Add(sample ...*SSFSample) { if s.Batch == nil { s.Batch = []*SSFSample{} } s.Batch = append(s.Batch, sample...) }
[ "func", "(", "s", "*", "Samples", ")", "Add", "(", "sample", "...", "*", "SSFSample", ")", "{", "if", "s", ".", "Batch", "==", "nil", "{", "s", ".", "Batch", "=", "[", "]", "*", "SSFSample", "{", "}", "\n", "}", "\n", "s", ".", "Batch", "=", ...
// Add appends a sample to the batch of samples.
[ "Add", "appends", "a", "sample", "to", "the", "batch", "of", "samples", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L28-L33
13,428
stripe/veneur
ssf/samples.go
Timestamp
func Timestamp(ts time.Time) SampleOption { return func(s *SSFSample) { s.Timestamp = ts.UnixNano() } }
go
func Timestamp(ts time.Time) SampleOption { return func(s *SSFSample) { s.Timestamp = ts.UnixNano() } }
[ "func", "Timestamp", "(", "ts", "time", ".", "Time", ")", "SampleOption", "{", "return", "func", "(", "s", "*", "SSFSample", ")", "{", "s", ".", "Timestamp", "=", "ts", ".", "UnixNano", "(", ")", "\n", "}", "\n", "}" ]
// Timestamp is a functional option for creating an SSFSample. It sets // the timestamp field on the sample to the timestamp passed.
[ "Timestamp", "is", "a", "functional", "option", "for", "creating", "an", "SSFSample", ".", "It", "sets", "the", "timestamp", "field", "on", "the", "sample", "to", "the", "timestamp", "passed", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L57-L61
13,429
stripe/veneur
ssf/samples.go
TimeUnit
func TimeUnit(resolution time.Duration) SampleOption { return func(s *SSFSample) { if unit, ok := resolutions[resolution]; ok { s.Unit = unit } } }
go
func TimeUnit(resolution time.Duration) SampleOption { return func(s *SSFSample) { if unit, ok := resolutions[resolution]; ok { s.Unit = unit } } }
[ "func", "TimeUnit", "(", "resolution", "time", ".", "Duration", ")", "SampleOption", "{", "return", "func", "(", "s", "*", "SSFSample", ")", "{", "if", "unit", ",", "ok", ":=", "resolutions", "[", "resolution", "]", ";", "ok", "{", "s", ".", "Unit", ...
// TimeUnit sets the unit on a sample to the given resolution's SI // unit symbol. Valid resolutions are the time duration constants from // Nanosecond through Hour. The non-SI units "minute" and "hour" are // represented by "min" and "h" respectively. // // If a resolution is passed that does not correspond exactly to...
[ "TimeUnit", "sets", "the", "unit", "on", "a", "sample", "to", "the", "given", "resolution", "s", "SI", "unit", "symbol", ".", "Valid", "resolutions", "are", "the", "time", "duration", "constants", "from", "Nanosecond", "through", "Hour", ".", "The", "non", ...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L93-L99
13,430
stripe/veneur
ssf/samples.go
Gauge
func Gauge(name string, value float32, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_GAUGE, Name: name, Value: value, Tags: tags, SampleRate: 1.0, }, opts) }
go
func Gauge(name string, value float32, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_GAUGE, Name: name, Value: value, Tags: tags, SampleRate: 1.0, }, opts) }
[ "func", "Gauge", "(", "name", "string", ",", "value", "float32", ",", "tags", "map", "[", "string", "]", "string", ",", "opts", "...", "SampleOption", ")", "*", "SSFSample", "{", "return", "create", "(", "&", "SSFSample", "{", "Metric", ":", "SSFSample_G...
// Gauge returns an SSFSample representing a gauge at a certain // value. It's a convenience wrapper around constructing SSFSample // objects.
[ "Gauge", "returns", "an", "SSFSample", "representing", "a", "gauge", "at", "a", "certain", "value", ".", "It", "s", "a", "convenience", "wrapper", "around", "constructing", "SSFSample", "objects", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L153-L161
13,431
stripe/veneur
ssf/samples.go
Histogram
func Histogram(name string, value float32, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_HISTOGRAM, Name: name, Value: value, Tags: tags, SampleRate: 1.0, }, opts) }
go
func Histogram(name string, value float32, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_HISTOGRAM, Name: name, Value: value, Tags: tags, SampleRate: 1.0, }, opts) }
[ "func", "Histogram", "(", "name", "string", ",", "value", "float32", ",", "tags", "map", "[", "string", "]", "string", ",", "opts", "...", "SampleOption", ")", "*", "SSFSample", "{", "return", "create", "(", "&", "SSFSample", "{", "Metric", ":", "SSFSamp...
// Histogram returns an SSFSample representing a value on a histogram, // like a timer or other range. It's a convenience wrapper around // constructing SSFSample objects.
[ "Histogram", "returns", "an", "SSFSample", "representing", "a", "value", "on", "a", "histogram", "like", "a", "timer", "or", "other", "range", ".", "It", "s", "a", "convenience", "wrapper", "around", "constructing", "SSFSample", "objects", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L166-L174
13,432
stripe/veneur
ssf/samples.go
Set
func Set(name string, value string, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_SET, Name: name, Message: value, Tags: tags, SampleRate: 1.0, }, opts) }
go
func Set(name string, value string, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_SET, Name: name, Message: value, Tags: tags, SampleRate: 1.0, }, opts) }
[ "func", "Set", "(", "name", "string", ",", "value", "string", ",", "tags", "map", "[", "string", "]", "string", ",", "opts", "...", "SampleOption", ")", "*", "SSFSample", "{", "return", "create", "(", "&", "SSFSample", "{", "Metric", ":", "SSFSample_SET"...
// Set returns an SSFSample representing a value on a set, useful for // counting the unique values that occur in a certain time bound.
[ "Set", "returns", "an", "SSFSample", "representing", "a", "value", "on", "a", "set", "useful", "for", "counting", "the", "unique", "values", "that", "occur", "in", "a", "certain", "time", "bound", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L178-L186
13,433
stripe/veneur
ssf/samples.go
Status
func Status(name string, state SSFSample_Status, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_STATUS, Name: name, Status: state, Tags: tags, SampleRate: 1.0, }, opts) }
go
func Status(name string, state SSFSample_Status, tags map[string]string, opts ...SampleOption) *SSFSample { return create(&SSFSample{ Metric: SSFSample_STATUS, Name: name, Status: state, Tags: tags, SampleRate: 1.0, }, opts) }
[ "func", "Status", "(", "name", "string", ",", "state", "SSFSample_Status", ",", "tags", "map", "[", "string", "]", "string", ",", "opts", "...", "SampleOption", ")", "*", "SSFSample", "{", "return", "create", "(", "&", "SSFSample", "{", "Metric", ":", "S...
// Status returns an SSFSample capturing the reported state // of a service
[ "Status", "returns", "an", "SSFSample", "capturing", "the", "reported", "state", "of", "a", "service" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/ssf/samples.go#L197-L205
13,434
stripe/veneur
sinks/sinks.go
IsAcceptableMetric
func IsAcceptableMetric(metric samplers.InterMetric, sink MetricSink) bool { if metric.Sinks == nil { return true } return metric.Sinks.RouteTo(sink.Name()) }
go
func IsAcceptableMetric(metric samplers.InterMetric, sink MetricSink) bool { if metric.Sinks == nil { return true } return metric.Sinks.RouteTo(sink.Name()) }
[ "func", "IsAcceptableMetric", "(", "metric", "samplers", ".", "InterMetric", ",", "sink", "MetricSink", ")", "bool", "{", "if", "metric", ".", "Sinks", "==", "nil", "{", "return", "true", "\n", "}", "\n", "return", "metric", ".", "Sinks", ".", "RouteTo", ...
// IsAcceptableMetric returns true if a metric is meant to be ingested // by a given sink.
[ "IsAcceptableMetric", "returns", "true", "if", "a", "metric", "is", "meant", "to", "be", "ingested", "by", "a", "given", "sink", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/sinks.go#L51-L56
13,435
stripe/veneur
tdigest/analysis/main.go
runOnce
func runOnce(distribution func() float64, compression float64, samples int, distname string, run int, deviations, centroidErrors, errors, sizes *csv.Writer) { td := tdigest.NewMerging(compression, true) allSamples := make([]float64, samples) for i := 0; i < samples; i++ { sample := distribution() td.Add(sample,...
go
func runOnce(distribution func() float64, compression float64, samples int, distname string, run int, deviations, centroidErrors, errors, sizes *csv.Writer) { td := tdigest.NewMerging(compression, true) allSamples := make([]float64, samples) for i := 0; i < samples; i++ { sample := distribution() td.Add(sample,...
[ "func", "runOnce", "(", "distribution", "func", "(", ")", "float64", ",", "compression", "float64", ",", "samples", "int", ",", "distname", "string", ",", "run", "int", ",", "deviations", ",", "centroidErrors", ",", "errors", ",", "sizes", "*", "csv", ".",...
// populate a single t-digest, of a given compression, with a given number of // samples, drawn from the given distribution function // then writes various statistics to the given CSVs
[ "populate", "a", "single", "t", "-", "digest", "of", "a", "given", "compression", "with", "a", "given", "number", "of", "samples", "drawn", "from", "the", "given", "distribution", "function", "then", "writes", "various", "statistics", "to", "the", "given", "...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/analysis/main.go#L19-L124
13,436
stripe/veneur
proxysrv/client_conn_map.go
Get
func (m *clientConnMap) Get(dest string) (conn *grpc.ClientConn, ok bool) { m.RLock() conn, ok = m.conns[dest] m.RUnlock() return }
go
func (m *clientConnMap) Get(dest string) (conn *grpc.ClientConn, ok bool) { m.RLock() conn, ok = m.conns[dest] m.RUnlock() return }
[ "func", "(", "m", "*", "clientConnMap", ")", "Get", "(", "dest", "string", ")", "(", "conn", "*", "grpc", ".", "ClientConn", ",", "ok", "bool", ")", "{", "m", ".", "RLock", "(", ")", "\n", "conn", ",", "ok", "=", "m", ".", "conns", "[", "dest",...
// Return a gRPC connection for the input destination. The ok value indicates // if the key was found in the map.
[ "Return", "a", "gRPC", "connection", "for", "the", "input", "destination", ".", "The", "ok", "value", "indicates", "if", "the", "key", "was", "found", "in", "the", "map", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxysrv/client_conn_map.go#L27-L33
13,437
stripe/veneur
proxysrv/client_conn_map.go
Add
func (m *clientConnMap) Add(dest string) error { // If the connection already exists, just exit early if _, ok := m.Get(dest); ok { return nil } conn, err := grpc.Dial(dest, m.options...) m.Lock() _, ok := m.conns[dest] if !ok && err == nil { m.conns[dest] = conn } m.Unlock() if ok && err == nil { _ ...
go
func (m *clientConnMap) Add(dest string) error { // If the connection already exists, just exit early if _, ok := m.Get(dest); ok { return nil } conn, err := grpc.Dial(dest, m.options...) m.Lock() _, ok := m.conns[dest] if !ok && err == nil { m.conns[dest] = conn } m.Unlock() if ok && err == nil { _ ...
[ "func", "(", "m", "*", "clientConnMap", ")", "Add", "(", "dest", "string", ")", "error", "{", "// If the connection already exists, just exit early", "if", "_", ",", "ok", ":=", "m", ".", "Get", "(", "dest", ")", ";", "ok", "{", "return", "nil", "\n", "}...
// Add the destination to the map, and open a new connection to it. If the // destination already exists, this is a no-op.
[ "Add", "the", "destination", "to", "the", "map", "and", "open", "a", "new", "connection", "to", "it", ".", "If", "the", "destination", "already", "exists", "this", "is", "a", "no", "-", "op", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxysrv/client_conn_map.go#L37-L57
13,438
stripe/veneur
proxysrv/client_conn_map.go
Delete
func (m *clientConnMap) Delete(dest string) { m.Lock() if conn, ok := m.conns[dest]; ok { _ = conn.Close() } delete(m.conns, dest) m.Unlock() }
go
func (m *clientConnMap) Delete(dest string) { m.Lock() if conn, ok := m.conns[dest]; ok { _ = conn.Close() } delete(m.conns, dest) m.Unlock() }
[ "func", "(", "m", "*", "clientConnMap", ")", "Delete", "(", "dest", "string", ")", "{", "m", ".", "Lock", "(", ")", "\n\n", "if", "conn", ",", "ok", ":=", "m", ".", "conns", "[", "dest", "]", ";", "ok", "{", "_", "=", "conn", ".", "Close", "(...
// Delete a destination from the map and close the associated connection. This // is a no-op if the destination doesn't exist.
[ "Delete", "a", "destination", "from", "the", "map", "and", "close", "the", "associated", "connection", ".", "This", "is", "a", "no", "-", "op", "if", "the", "destination", "doesn", "t", "exist", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxysrv/client_conn_map.go#L61-L70
13,439
stripe/veneur
proxysrv/client_conn_map.go
Keys
func (m *clientConnMap) Keys() []string { m.RLock() res := make([]string, 0, len(m.conns)) for k := range m.conns { res = append(res, k) } m.RUnlock() return res }
go
func (m *clientConnMap) Keys() []string { m.RLock() res := make([]string, 0, len(m.conns)) for k := range m.conns { res = append(res, k) } m.RUnlock() return res }
[ "func", "(", "m", "*", "clientConnMap", ")", "Keys", "(", ")", "[", "]", "string", "{", "m", ".", "RLock", "(", ")", "\n\n", "res", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "m", ".", "conns", ")", ")", "\n", "for", ...
// Keys returns all of the destinations in the map.
[ "Keys", "returns", "all", "of", "the", "destinations", "in", "the", "map", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxysrv/client_conn_map.go#L73-L83
13,440
stripe/veneur
proxysrv/client_conn_map.go
Clear
func (m *clientConnMap) Clear() { m.Lock() for _, conn := range m.conns { _ = conn.Close() } m.conns = make(map[string]*grpc.ClientConn) m.Unlock() }
go
func (m *clientConnMap) Clear() { m.Lock() for _, conn := range m.conns { _ = conn.Close() } m.conns = make(map[string]*grpc.ClientConn) m.Unlock() }
[ "func", "(", "m", "*", "clientConnMap", ")", "Clear", "(", ")", "{", "m", ".", "Lock", "(", ")", "\n\n", "for", "_", ",", "conn", ":=", "range", "m", ".", "conns", "{", "_", "=", "conn", ".", "Close", "(", ")", "\n", "}", "\n\n", "m", ".", ...
// Clear removes all keys from the map and closes each associated connection.
[ "Clear", "removes", "all", "keys", "from", "the", "map", "and", "closes", "each", "associated", "connection", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/proxysrv/client_conn_map.go#L86-L95
13,441
stripe/veneur
sinks/signalfx/signalfx.go
NewClient
func NewClient(endpoint, apiKey string, client *http.Client) DPClient { baseURL, err := url.Parse(endpoint) if err != nil { panic(fmt.Sprintf("Could not parse endpoint base URL %q: %v", endpoint, err)) } httpSink := sfxclient.NewHTTPSink() httpSink.AuthToken = apiKey httpSink.DatapointEndpoint = baseURL.Resolve...
go
func NewClient(endpoint, apiKey string, client *http.Client) DPClient { baseURL, err := url.Parse(endpoint) if err != nil { panic(fmt.Sprintf("Could not parse endpoint base URL %q: %v", endpoint, err)) } httpSink := sfxclient.NewHTTPSink() httpSink.AuthToken = apiKey httpSink.DatapointEndpoint = baseURL.Resolve...
[ "func", "NewClient", "(", "endpoint", ",", "apiKey", "string", ",", "client", "*", "http", ".", "Client", ")", "DPClient", "{", "baseURL", ",", "err", ":=", "url", ".", "Parse", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(",...
// NewClient constructs a new signalfx HTTP client for the given // endpoint and API token.
[ "NewClient", "constructs", "a", "new", "signalfx", "HTTP", "client", "for", "the", "given", "endpoint", "and", "API", "token", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/signalfx/signalfx.go#L156-L167
13,442
stripe/veneur
sinks/signalfx/signalfx.go
NewSignalFxSink
func NewSignalFxSink(hostnameTag string, hostname string, commonDimensions map[string]string, log *logrus.Logger, client DPClient, varyBy string, perTagClients map[string]DPClient, metricNamePrefixDrops []string, metricTagPrefixDrops []string, derivedMetrics samplers.DerivedMetricsProcessor, maxPointsInBatch int) (*Sig...
go
func NewSignalFxSink(hostnameTag string, hostname string, commonDimensions map[string]string, log *logrus.Logger, client DPClient, varyBy string, perTagClients map[string]DPClient, metricNamePrefixDrops []string, metricTagPrefixDrops []string, derivedMetrics samplers.DerivedMetricsProcessor, maxPointsInBatch int) (*Sig...
[ "func", "NewSignalFxSink", "(", "hostnameTag", "string", ",", "hostname", "string", ",", "commonDimensions", "map", "[", "string", "]", "string", ",", "log", "*", "logrus", ".", "Logger", ",", "client", "DPClient", ",", "varyBy", "string", ",", "perTagClients"...
// NewSignalFxSink creates a new SignalFx sink for metrics.
[ "NewSignalFxSink", "creates", "a", "new", "SignalFx", "sink", "for", "metrics", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/signalfx/signalfx.go#L170-L184
13,443
stripe/veneur
sinks/signalfx/signalfx.go
Start
func (sfx *SignalFxSink) Start(traceClient *trace.Client) error { sfx.traceClient = traceClient return nil }
go
func (sfx *SignalFxSink) Start(traceClient *trace.Client) error { sfx.traceClient = traceClient return nil }
[ "func", "(", "sfx", "*", "SignalFxSink", ")", "Start", "(", "traceClient", "*", "trace", ".", "Client", ")", "error", "{", "sfx", ".", "traceClient", "=", "traceClient", "\n", "return", "nil", "\n", "}" ]
// Start begins the sink. For SignalFx this is a noop.
[ "Start", "begins", "the", "sink", ".", "For", "SignalFx", "this", "is", "a", "noop", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/signalfx/signalfx.go#L192-L195
13,444
stripe/veneur
sinks/signalfx/signalfx.go
client
func (sfx *SignalFxSink) client(key string) DPClient { if cl, ok := sfx.clientsByTagValue[key]; ok { return cl } return sfx.defaultClient }
go
func (sfx *SignalFxSink) client(key string) DPClient { if cl, ok := sfx.clientsByTagValue[key]; ok { return cl } return sfx.defaultClient }
[ "func", "(", "sfx", "*", "SignalFxSink", ")", "client", "(", "key", "string", ")", "DPClient", "{", "if", "cl", ",", "ok", ":=", "sfx", ".", "clientsByTagValue", "[", "key", "]", ";", "ok", "{", "return", "cl", "\n", "}", "\n", "return", "sfx", "."...
// client returns a client that can be used to submit to vary-by tag's // value. If no client is specified for that tag value, the default // client is returned.
[ "client", "returns", "a", "client", "that", "can", "be", "used", "to", "submit", "to", "vary", "-", "by", "tag", "s", "value", ".", "If", "no", "client", "is", "specified", "for", "that", "tag", "value", "the", "default", "client", "is", "returned", "....
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/signalfx/signalfx.go#L200-L205
13,445
stripe/veneur
sinks/signalfx/signalfx.go
newPointCollection
func (sfx *SignalFxSink) newPointCollection() *collection { return &collection{ sink: sfx, points: []*datapoint.Datapoint{}, pointsByKey: map[string][]*datapoint.Datapoint{}, } }
go
func (sfx *SignalFxSink) newPointCollection() *collection { return &collection{ sink: sfx, points: []*datapoint.Datapoint{}, pointsByKey: map[string][]*datapoint.Datapoint{}, } }
[ "func", "(", "sfx", "*", "SignalFxSink", ")", "newPointCollection", "(", ")", "*", "collection", "{", "return", "&", "collection", "{", "sink", ":", "sfx", ",", "points", ":", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "}", ",", "pointsByKey", ...
// newPointCollection creates an empty collection object and returns it
[ "newPointCollection", "creates", "an", "empty", "collection", "object", "and", "returns", "it" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/signalfx/signalfx.go#L208-L214
13,446
stripe/veneur
sinks/signalfx/signalfx.go
FlushOtherSamples
func (sfx *SignalFxSink) FlushOtherSamples(ctx context.Context, samples []ssf.SSFSample) { span, _ := trace.StartSpanFromContext(ctx, "") defer span.ClientFinish(sfx.traceClient) var countFailed = 0 var countSuccess = 0 for _, sample := range samples { if _, ok := sample.Tags[dogstatsd.EventIdentifierKey]; ok { ...
go
func (sfx *SignalFxSink) FlushOtherSamples(ctx context.Context, samples []ssf.SSFSample) { span, _ := trace.StartSpanFromContext(ctx, "") defer span.ClientFinish(sfx.traceClient) var countFailed = 0 var countSuccess = 0 for _, sample := range samples { if _, ok := sample.Tags[dogstatsd.EventIdentifierKey]; ok { ...
[ "func", "(", "sfx", "*", "SignalFxSink", ")", "FlushOtherSamples", "(", "ctx", "context", ".", "Context", ",", "samples", "[", "]", "ssf", ".", "SSFSample", ")", "{", "span", ",", "_", ":=", "trace", ".", "StartSpanFromContext", "(", "ctx", ",", "\"", ...
// FlushOtherSamples sends events to SignalFx. Event type samples will be serialized as SFX // Events directly. All other metric types are ignored
[ "FlushOtherSamples", "sends", "events", "to", "SignalFx", ".", "Event", "type", "samples", "will", "be", "serialized", "as", "SFX", "Events", "directly", ".", "All", "other", "metric", "types", "are", "ignored" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/signalfx/signalfx.go#L315-L336
13,447
stripe/veneur
server.go
HandleTracePacket
func (s *Server) HandleTracePacket(packet []byte) { samples := &ssf.Samples{} defer metrics.Report(s.TraceClient, samples) // Unlike metrics, protobuf shouldn't have an issue with 0-length packets if len(packet) == 0 { s.Statsd.Count("ssf.error_total", 1, []string{"ssf_format:packet", "packet_type:unknown", "rea...
go
func (s *Server) HandleTracePacket(packet []byte) { samples := &ssf.Samples{} defer metrics.Report(s.TraceClient, samples) // Unlike metrics, protobuf shouldn't have an issue with 0-length packets if len(packet) == 0 { s.Statsd.Count("ssf.error_total", 1, []string{"ssf_format:packet", "packet_type:unknown", "rea...
[ "func", "(", "s", "*", "Server", ")", "HandleTracePacket", "(", "packet", "[", "]", "byte", ")", "{", "samples", ":=", "&", "ssf", ".", "Samples", "{", "}", "\n", "defer", "metrics", ".", "Report", "(", "s", ".", "TraceClient", ",", "samples", ")", ...
// HandleTracePacket accepts an incoming packet as bytes and sends it to the // appropriate worker.
[ "HandleTracePacket", "accepts", "an", "incoming", "packet", "as", "bytes", "and", "sends", "it", "to", "the", "appropriate", "worker", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L854-L883
13,448
stripe/veneur
server.go
ReadMetricSocket
func (s *Server) ReadMetricSocket(serverConn net.PacketConn, packetPool *sync.Pool) { for { buf := packetPool.Get().([]byte) n, _, err := serverConn.ReadFrom(buf) if err != nil { log.WithError(err).Error("Error reading from UDP metrics socket") continue } s.processMetricPacket(n, buf, packetPool) } }
go
func (s *Server) ReadMetricSocket(serverConn net.PacketConn, packetPool *sync.Pool) { for { buf := packetPool.Get().([]byte) n, _, err := serverConn.ReadFrom(buf) if err != nil { log.WithError(err).Error("Error reading from UDP metrics socket") continue } s.processMetricPacket(n, buf, packetPool) } }
[ "func", "(", "s", "*", "Server", ")", "ReadMetricSocket", "(", "serverConn", "net", ".", "PacketConn", ",", "packetPool", "*", "sync", ".", "Pool", ")", "{", "for", "{", "buf", ":=", "packetPool", ".", "Get", "(", ")", ".", "(", "[", "]", "byte", "...
// ReadMetricSocket listens for available packets to handle.
[ "ReadMetricSocket", "listens", "for", "available", "packets", "to", "handle", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L931-L941
13,449
stripe/veneur
server.go
processMetricPacket
func (s *Server) processMetricPacket(numBytes int, buf []byte, packetPool *sync.Pool) { if numBytes > s.metricMaxLength { metrics.ReportOne(s.TraceClient, ssf.Count("packet.error_total", 1, map[string]string{"packet_type": "unknown", "reason": "toolong"})) return } // statsd allows multiple packets to be joined...
go
func (s *Server) processMetricPacket(numBytes int, buf []byte, packetPool *sync.Pool) { if numBytes > s.metricMaxLength { metrics.ReportOne(s.TraceClient, ssf.Count("packet.error_total", 1, map[string]string{"packet_type": "unknown", "reason": "toolong"})) return } // statsd allows multiple packets to be joined...
[ "func", "(", "s", "*", "Server", ")", "processMetricPacket", "(", "numBytes", "int", ",", "buf", "[", "]", "byte", ",", "packetPool", "*", "sync", ".", "Pool", ")", "{", "if", "numBytes", ">", "s", ".", "metricMaxLength", "{", "metrics", ".", "ReportOn...
// Splits the read metric packet into multiple metrics and handles them
[ "Splits", "the", "read", "metric", "packet", "into", "multiple", "metrics", "and", "handles", "them" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L944-L965
13,450
stripe/veneur
server.go
ReadStatsdDatagramSocket
func (s *Server) ReadStatsdDatagramSocket(serverConn *net.UnixConn, packetPool *sync.Pool) { for { buf := packetPool.Get().([]byte) n, _, err := serverConn.ReadFromUnix(buf) if err != nil { select { case <-s.shutdown: log.WithError(err).Info("Ignoring ReadFrom error while shutting down") return ...
go
func (s *Server) ReadStatsdDatagramSocket(serverConn *net.UnixConn, packetPool *sync.Pool) { for { buf := packetPool.Get().([]byte) n, _, err := serverConn.ReadFromUnix(buf) if err != nil { select { case <-s.shutdown: log.WithError(err).Info("Ignoring ReadFrom error while shutting down") return ...
[ "func", "(", "s", "*", "Server", ")", "ReadStatsdDatagramSocket", "(", "serverConn", "*", "net", ".", "UnixConn", ",", "packetPool", "*", "sync", ".", "Pool", ")", "{", "for", "{", "buf", ":=", "packetPool", ".", "Get", "(", ")", ".", "(", "[", "]", ...
// ReadStatsdDatagramSocket reads statsd metrics packets from connection off a unix datagram socket.
[ "ReadStatsdDatagramSocket", "reads", "statsd", "metrics", "packets", "from", "connection", "off", "a", "unix", "datagram", "socket", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L968-L985
13,451
stripe/veneur
server.go
ReadSSFPacketSocket
func (s *Server) ReadSSFPacketSocket(serverConn net.PacketConn, packetPool *sync.Pool) { // TODO This is duplicated from ReadMetricSocket and feels like it could be it's // own function? p := packetPool.Get().([]byte) if len(p) == 0 { log.WithField("len", len(p)).Fatal( "packetPool making empty slices: trace_m...
go
func (s *Server) ReadSSFPacketSocket(serverConn net.PacketConn, packetPool *sync.Pool) { // TODO This is duplicated from ReadMetricSocket and feels like it could be it's // own function? p := packetPool.Get().([]byte) if len(p) == 0 { log.WithField("len", len(p)).Fatal( "packetPool making empty slices: trace_m...
[ "func", "(", "s", "*", "Server", ")", "ReadSSFPacketSocket", "(", "serverConn", "net", ".", "PacketConn", ",", "packetPool", "*", "sync", ".", "Pool", ")", "{", "// TODO This is duplicated from ReadMetricSocket and feels like it could be it's", "// own function?", "p", ...
// ReadSSFPacketSocket reads SSF packets off a packet connection.
[ "ReadSSFPacketSocket", "reads", "SSF", "packets", "off", "a", "packet", "connection", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L988-L1018
13,452
stripe/veneur
server.go
ReadTCPSocket
func (s *Server) ReadTCPSocket(listener net.Listener) { for { conn, err := listener.Accept() if err != nil { select { case <-s.shutdown: // occurs when cleanly shutting down the server e.g. in tests; ignore errors log.WithError(err).Info("Ignoring Accept error while shutting down") return defa...
go
func (s *Server) ReadTCPSocket(listener net.Listener) { for { conn, err := listener.Accept() if err != nil { select { case <-s.shutdown: // occurs when cleanly shutting down the server e.g. in tests; ignore errors log.WithError(err).Info("Ignoring Accept error while shutting down") return defa...
[ "func", "(", "s", "*", "Server", ")", "ReadTCPSocket", "(", "listener", "net", ".", "Listener", ")", "{", "for", "{", "conn", ",", "err", ":=", "listener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "select", "{", "case", "<-", ...
// ReadTCPSocket listens on Server.TCPAddr for new connections, starting a goroutine for each.
[ "ReadTCPSocket", "listens", "on", "Server", ".", "TCPAddr", "for", "new", "connections", "starting", "a", "goroutine", "for", "each", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L1146-L1162
13,453
stripe/veneur
server.go
HTTPServe
func (s *Server) HTTPServe() { var prf interface { Stop() } // We want to make sure the profile is stopped // exactly once (and only once), even if the // shutdown pre-hook does not run (which it may not) profileStopOnce := sync.Once{} if s.enableProfiling { profileStartOnce.Do(func() { prf = profile.St...
go
func (s *Server) HTTPServe() { var prf interface { Stop() } // We want to make sure the profile is stopped // exactly once (and only once), even if the // shutdown pre-hook does not run (which it may not) profileStopOnce := sync.Once{} if s.enableProfiling { profileStartOnce.Do(func() { prf = profile.St...
[ "func", "(", "s", "*", "Server", ")", "HTTPServe", "(", ")", "{", "var", "prf", "interface", "{", "Stop", "(", ")", "\n", "}", "\n\n", "// We want to make sure the profile is stopped", "// exactly once (and only once), even if the", "// shutdown pre-hook does not run (whi...
// HTTPServe starts the HTTP server and listens perpetually until it encounters an unrecoverable error.
[ "HTTPServe", "starts", "the", "HTTP", "server", "and", "listens", "perpetually", "until", "it", "encounters", "an", "unrecoverable", "error", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L1190-L1238
13,454
stripe/veneur
server.go
registerPlugin
func (s *Server) registerPlugin(p plugins.Plugin) { s.pluginMtx.Lock() defer s.pluginMtx.Unlock() s.plugins = append(s.plugins, p) }
go
func (s *Server) registerPlugin(p plugins.Plugin) { s.pluginMtx.Lock() defer s.pluginMtx.Unlock() s.plugins = append(s.plugins, p) }
[ "func", "(", "s", "*", "Server", ")", "registerPlugin", "(", "p", "plugins", ".", "Plugin", ")", "{", "s", ".", "pluginMtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "pluginMtx", ".", "Unlock", "(", ")", "\n", "s", ".", "plugins", "=", "ap...
// registerPlugin registers a plugin for use // on the veneur server. It is blocking // and not threadsafe.
[ "registerPlugin", "registers", "a", "plugin", "for", "use", "on", "the", "veneur", "server", ".", "It", "is", "blocking", "and", "not", "threadsafe", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L1309-L1313
13,455
stripe/veneur
server.go
CalculateTickDelay
func CalculateTickDelay(interval time.Duration, t time.Time) time.Duration { return t.Truncate(interval).Add(interval).Sub(t) }
go
func CalculateTickDelay(interval time.Duration, t time.Time) time.Duration { return t.Truncate(interval).Add(interval).Sub(t) }
[ "func", "CalculateTickDelay", "(", "interval", "time", ".", "Duration", ",", "t", "time", ".", "Time", ")", "time", ".", "Duration", "{", "return", "t", ".", "Truncate", "(", "interval", ")", ".", "Add", "(", "interval", ")", ".", "Sub", "(", "t", ")...
// CalculateTickDelay takes the provided time, `Truncate`s it a rounded-down // multiple of `interval`, then adds `interval` back to find the "next" tick.
[ "CalculateTickDelay", "takes", "the", "provided", "time", "Truncate", "s", "it", "a", "rounded", "-", "down", "multiple", "of", "interval", "then", "adds", "interval", "back", "to", "find", "the", "next", "tick", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L1325-L1327
13,456
stripe/veneur
server.go
setSinkExcludedTags
func setSinkExcludedTags(excludeRules []string, metricSinks []sinks.MetricSink) { type excludableSink interface { SetExcludedTags([]string) } for _, sink := range metricSinks { if s, ok := sink.(excludableSink); ok { excludedTags := generateExcludedTags(excludeRules, sink.Name()) log.WithFields(logrus.Fie...
go
func setSinkExcludedTags(excludeRules []string, metricSinks []sinks.MetricSink) { type excludableSink interface { SetExcludedTags([]string) } for _, sink := range metricSinks { if s, ok := sink.(excludableSink); ok { excludedTags := generateExcludedTags(excludeRules, sink.Name()) log.WithFields(logrus.Fie...
[ "func", "setSinkExcludedTags", "(", "excludeRules", "[", "]", "string", ",", "metricSinks", "[", "]", "sinks", ".", "MetricSink", ")", "{", "type", "excludableSink", "interface", "{", "SetExcludedTags", "(", "[", "]", "string", ")", "\n", "}", "\n\n", "for",...
// Set the list of tags to exclude on each sink
[ "Set", "the", "list", "of", "tags", "to", "exclude", "on", "each", "sink" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/server.go#L1330-L1345
13,457
stripe/veneur
protocol/wire.go
ValidTrace
func ValidTrace(span *ssf.SSFSpan) bool { return span.Id != 0 && span.TraceId != 0 && span.StartTimestamp != 0 && span.EndTimestamp != 0 && span.Name != "" }
go
func ValidTrace(span *ssf.SSFSpan) bool { return span.Id != 0 && span.TraceId != 0 && span.StartTimestamp != 0 && span.EndTimestamp != 0 && span.Name != "" }
[ "func", "ValidTrace", "(", "span", "*", "ssf", ".", "SSFSpan", ")", "bool", "{", "return", "span", ".", "Id", "!=", "0", "&&", "span", ".", "TraceId", "!=", "0", "&&", "span", ".", "StartTimestamp", "!=", "0", "&&", "span", ".", "EndTimestamp", "!=",...
// ValidTrace returns true if an SSFSpan contains all data necessary // to synthesize a span that can be used as part of a trace.
[ "ValidTrace", "returns", "true", "if", "an", "SSFSpan", "contains", "all", "data", "necessary", "to", "synthesize", "a", "span", "that", "can", "be", "used", "as", "part", "of", "a", "trace", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/protocol/wire.go#L82-L88
13,458
stripe/veneur
protocol/wire.go
ValidateTrace
func ValidateTrace(span *ssf.SSFSpan) error { if !ValidTrace(span) { return &InvalidTrace{span} } return nil }
go
func ValidateTrace(span *ssf.SSFSpan) error { if !ValidTrace(span) { return &InvalidTrace{span} } return nil }
[ "func", "ValidateTrace", "(", "span", "*", "ssf", ".", "SSFSpan", ")", "error", "{", "if", "!", "ValidTrace", "(", "span", ")", "{", "return", "&", "InvalidTrace", "{", "span", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ValidateTrace is identical to ValidTrace, except instead of returning // a boolean, it returns a non-nil error if the SSFSpan cannot be interpreted // as a span, and nil otherwise.
[ "ValidateTrace", "is", "identical", "to", "ValidTrace", "except", "instead", "of", "returning", "a", "boolean", "it", "returns", "a", "non", "-", "nil", "error", "if", "the", "SSFSpan", "cannot", "be", "interpreted", "as", "a", "span", "and", "nil", "otherwi...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/protocol/wire.go#L93-L98
13,459
stripe/veneur
protocol/wire.go
WriteSSF
func WriteSSF(out io.Writer, ssf *ssf.SSFSpan) (int, error) { pbuf := pbufPool.Get().(*proto.Buffer) err := pbuf.Marshal(ssf) if err != nil { // This is not a framing error, as we haven't written // anything to the stream yet. return 0, err } defer func() { // Make sure we reset the scratch protobuffer (by...
go
func WriteSSF(out io.Writer, ssf *ssf.SSFSpan) (int, error) { pbuf := pbufPool.Get().(*proto.Buffer) err := pbuf.Marshal(ssf) if err != nil { // This is not a framing error, as we haven't written // anything to the stream yet. return 0, err } defer func() { // Make sure we reset the scratch protobuffer (by...
[ "func", "WriteSSF", "(", "out", "io", ".", "Writer", ",", "ssf", "*", "ssf", ".", "SSFSpan", ")", "(", "int", ",", "error", ")", "{", "pbuf", ":=", "pbufPool", ".", "Get", "(", ")", ".", "(", "*", "proto", ".", "Buffer", ")", "\n", "err", ":=",...
// WriteSSF writes an SSF span with a preceding v0 frame onto a stream // and returns the number of bytes written, as well as an error. // // If the error matches IsFramingError, the stream must be considered // poisoned and should not be re-used.
[ "WriteSSF", "writes", "an", "SSF", "span", "with", "a", "preceding", "v0", "frame", "onto", "a", "stream", "and", "returns", "the", "number", "of", "bytes", "written", "as", "well", "as", "an", "error", ".", "If", "the", "error", "matches", "IsFramingError...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/protocol/wire.go#L186-L212
13,460
stripe/veneur
sinks/datadog/datadog.go
NewDatadogMetricSink
func NewDatadogMetricSink(interval float64, flushMaxPerBody int, hostname string, tags []string, ddHostname string, apiKey string, httpClient *http.Client, log *logrus.Logger) (*DatadogMetricSink, error) { return &DatadogMetricSink{ HTTPClient: httpClient, APIKey: apiKey, DDHostname: ddHostnam...
go
func NewDatadogMetricSink(interval float64, flushMaxPerBody int, hostname string, tags []string, ddHostname string, apiKey string, httpClient *http.Client, log *logrus.Logger) (*DatadogMetricSink, error) { return &DatadogMetricSink{ HTTPClient: httpClient, APIKey: apiKey, DDHostname: ddHostnam...
[ "func", "NewDatadogMetricSink", "(", "interval", "float64", ",", "flushMaxPerBody", "int", ",", "hostname", "string", ",", "tags", "[", "]", "string", ",", "ddHostname", "string", ",", "apiKey", "string", ",", "httpClient", "*", "http", ".", "Client", ",", "...
// NewDatadogMetricSink creates a new Datadog sink for trace spans.
[ "NewDatadogMetricSink", "creates", "a", "new", "Datadog", "sink", "for", "trace", "spans", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/datadog/datadog.go#L83-L94
13,461
stripe/veneur
sinks/datadog/datadog.go
Flush
func (dd *DatadogMetricSink) Flush(ctx context.Context, interMetrics []samplers.InterMetric) error { span, _ := trace.StartSpanFromContext(ctx, "") defer span.ClientFinish(dd.traceClient) ddmetrics, checks := dd.finalizeMetrics(interMetrics) if len(checks) != 0 { // this endpoint is not documented to take an ar...
go
func (dd *DatadogMetricSink) Flush(ctx context.Context, interMetrics []samplers.InterMetric) error { span, _ := trace.StartSpanFromContext(ctx, "") defer span.ClientFinish(dd.traceClient) ddmetrics, checks := dd.finalizeMetrics(interMetrics) if len(checks) != 0 { // this endpoint is not documented to take an ar...
[ "func", "(", "dd", "*", "DatadogMetricSink", ")", "Flush", "(", "ctx", "context", ".", "Context", ",", "interMetrics", "[", "]", "samplers", ".", "InterMetric", ")", "error", "{", "span", ",", "_", ":=", "trace", ".", "StartSpanFromContext", "(", "ctx", ...
// Flush sends metrics to Datadog
[ "Flush", "sends", "metrics", "to", "Datadog" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/datadog/datadog.go#L108-L154
13,462
stripe/veneur
sinks/datadog/datadog.go
NewDatadogSpanSink
func NewDatadogSpanSink(address string, bufferSize int, httpClient *http.Client, log *logrus.Logger) (*DatadogSpanSink, error) { if bufferSize == 0 { bufferSize = datadogSpanBufferSize } return &DatadogSpanSink{ HTTPClient: httpClient, bufferSize: bufferSize, buffer: ring.New(bufferSize), mutex:...
go
func NewDatadogSpanSink(address string, bufferSize int, httpClient *http.Client, log *logrus.Logger) (*DatadogSpanSink, error) { if bufferSize == 0 { bufferSize = datadogSpanBufferSize } return &DatadogSpanSink{ HTTPClient: httpClient, bufferSize: bufferSize, buffer: ring.New(bufferSize), mutex:...
[ "func", "NewDatadogSpanSink", "(", "address", "string", ",", "bufferSize", "int", ",", "httpClient", "*", "http", ".", "Client", ",", "log", "*", "logrus", ".", "Logger", ")", "(", "*", "DatadogSpanSink", ",", "error", ")", "{", "if", "bufferSize", "==", ...
// NewDatadogSpanSink creates a new Datadog sink for trace spans.
[ "NewDatadogSpanSink", "creates", "a", "new", "Datadog", "sink", "for", "trace", "spans", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/datadog/datadog.go#L390-L403
13,463
stripe/veneur
sinks/datadog/datadog.go
Ingest
func (dd *DatadogSpanSink) Ingest(span *ssf.SSFSpan) error { if err := protocol.ValidateTrace(span); err != nil { return err } dd.mutex.Lock() defer dd.mutex.Unlock() dd.buffer.Value = span dd.buffer = dd.buffer.Next() return nil }
go
func (dd *DatadogSpanSink) Ingest(span *ssf.SSFSpan) error { if err := protocol.ValidateTrace(span); err != nil { return err } dd.mutex.Lock() defer dd.mutex.Unlock() dd.buffer.Value = span dd.buffer = dd.buffer.Next() return nil }
[ "func", "(", "dd", "*", "DatadogSpanSink", ")", "Ingest", "(", "span", "*", "ssf", ".", "SSFSpan", ")", "error", "{", "if", "err", ":=", "protocol", ".", "ValidateTrace", "(", "span", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// Ingest takes the span and adds it to the ringbuffer.
[ "Ingest", "takes", "the", "span", "and", "adds", "it", "to", "the", "ringbuffer", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/sinks/datadog/datadog.go#L417-L427
13,464
stripe/veneur
trace/client.go
Capacity
func Capacity(n uint) ClientParam { return func(cl *Client) error { cl.cap = n return nil } }
go
func Capacity(n uint) ClientParam { return func(cl *Client) error { cl.cap = n return nil } }
[ "func", "Capacity", "(", "n", "uint", ")", "ClientParam", "{", "return", "func", "(", "cl", "*", "Client", ")", "error", "{", "cl", ".", "cap", "=", "n", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Capacity indicates how many spans a client's channel should // accommodate. This parameter can be used on both generic and // networked backends.
[ "Capacity", "indicates", "how", "many", "spans", "a", "client", "s", "channel", "should", "accommodate", ".", "This", "parameter", "can", "be", "used", "on", "both", "generic", "and", "networked", "backends", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L137-L142
13,465
stripe/veneur
trace/client.go
BufferedSize
func BufferedSize(size uint) ClientParam { return func(cl *Client) error { if cl.backendParams != nil { cl.backendParams.bufferSize = size return nil } return ErrClientNotNetworked } }
go
func BufferedSize(size uint) ClientParam { return func(cl *Client) error { if cl.backendParams != nil { cl.backendParams.bufferSize = size return nil } return ErrClientNotNetworked } }
[ "func", "BufferedSize", "(", "size", "uint", ")", "ClientParam", "{", "return", "func", "(", "cl", "*", "Client", ")", "error", "{", "if", "cl", ".", "backendParams", "!=", "nil", "{", "cl", ".", "backendParams", ".", "bufferSize", "=", "size", "\n", "...
// BufferedSize indicates that a client should have a buffer size // bytes large. See the note on the Buffered option about flushing the // buffer.
[ "BufferedSize", "indicates", "that", "a", "client", "should", "have", "a", "buffer", "size", "bytes", "large", ".", "See", "the", "note", "on", "the", "Buffered", "option", "about", "flushing", "the", "buffer", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L163-L171
13,466
stripe/veneur
trace/client.go
FlushInterval
func FlushInterval(interval time.Duration) ClientParam { t := time.NewTicker(interval) return FlushChannel(t.C, t.Stop) }
go
func FlushInterval(interval time.Duration) ClientParam { t := time.NewTicker(interval) return FlushChannel(t.C, t.Stop) }
[ "func", "FlushInterval", "(", "interval", "time", ".", "Duration", ")", "ClientParam", "{", "t", ":=", "time", ".", "NewTicker", "(", "interval", ")", "\n", "return", "FlushChannel", "(", "t", ".", "C", ",", "t", ".", "Stop", ")", "\n", "}" ]
// FlushInterval sets up a buffered client to perform one synchronous // flush per time interval in a new goroutine. The goroutine closes // down when the Client's Close method is called. // // This uses a time.Ticker to trigger the flush, so will not trigger // multiple times if flushing should be slower than the trig...
[ "FlushInterval", "sets", "up", "a", "buffered", "client", "to", "perform", "one", "synchronous", "flush", "per", "time", "interval", "in", "a", "new", "goroutine", ".", "The", "goroutine", "closes", "down", "when", "the", "Client", "s", "Close", "method", "i...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L180-L183
13,467
stripe/veneur
trace/client.go
FlushChannel
func FlushChannel(ch <-chan time.Time, stop func()) ClientParam { return func(cl *Client) error { if cl.backendParams == nil { return ErrClientNotNetworked } cl.flush = func(ctx context.Context) { defer stop() for { select { case <-ch: _ = Flush(cl) case <-ctx.Done(): return } ...
go
func FlushChannel(ch <-chan time.Time, stop func()) ClientParam { return func(cl *Client) error { if cl.backendParams == nil { return ErrClientNotNetworked } cl.flush = func(ctx context.Context) { defer stop() for { select { case <-ch: _ = Flush(cl) case <-ctx.Done(): return } ...
[ "func", "FlushChannel", "(", "ch", "<-", "chan", "time", ".", "Time", ",", "stop", "func", "(", ")", ")", "ClientParam", "{", "return", "func", "(", "cl", "*", "Client", ")", "error", "{", "if", "cl", ".", "backendParams", "==", "nil", "{", "return",...
// FlushChannel sets up a buffered client to perform one synchronous // flush any time the given channel has a Time element ready. When the // Client is closed, FlushWith invokes the passed stop function. // // This functional option is mostly useful for tests; code intended to // be used in production should rely on F...
[ "FlushChannel", "sets", "up", "a", "buffered", "client", "to", "perform", "one", "synchronous", "flush", "any", "time", "the", "given", "channel", "has", "a", "Time", "element", "ready", ".", "When", "the", "Client", "is", "closed", "FlushWith", "invokes", "...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L192-L210
13,468
stripe/veneur
trace/client.go
MaxBackoffTime
func MaxBackoffTime(t time.Duration) ClientParam { return func(cl *Client) error { if cl.backendParams != nil { cl.backendParams.maxBackoff = t return nil } return ErrClientNotNetworked } }
go
func MaxBackoffTime(t time.Duration) ClientParam { return func(cl *Client) error { if cl.backendParams != nil { cl.backendParams.maxBackoff = t return nil } return ErrClientNotNetworked } }
[ "func", "MaxBackoffTime", "(", "t", "time", ".", "Duration", ")", "ClientParam", "{", "return", "func", "(", "cl", "*", "Client", ")", "error", "{", "if", "cl", ".", "backendParams", "!=", "nil", "{", "cl", ".", "backendParams", ".", "maxBackoff", "=", ...
// MaxBackoffTime sets the maximum time duration waited between // reconnection attempts. If this option is not used, the backend uses // DefaultMaxBackoff.
[ "MaxBackoffTime", "sets", "the", "maximum", "time", "duration", "waited", "between", "reconnection", "attempts", ".", "If", "this", "option", "is", "not", "used", "the", "backend", "uses", "DefaultMaxBackoff", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L228-L236
13,469
stripe/veneur
trace/client.go
ParallelBackends
func ParallelBackends(nBackends uint) ClientParam { return func(cl *Client) error { if cl.backendParams == nil { return ErrClientNotNetworked } cl.nBackends = nBackends return nil } }
go
func ParallelBackends(nBackends uint) ClientParam { return func(cl *Client) error { if cl.backendParams == nil { return ErrClientNotNetworked } cl.nBackends = nBackends return nil } }
[ "func", "ParallelBackends", "(", "nBackends", "uint", ")", "ClientParam", "{", "return", "func", "(", "cl", "*", "Client", ")", "error", "{", "if", "cl", ".", "backendParams", "==", "nil", "{", "return", "ErrClientNotNetworked", "\n", "}", "\n", "cl", ".",...
// ParallelBackends sets the number of parallel network backend // connections to send spans with. Each backend holds a connection to // an SSF receiver open.
[ "ParallelBackends", "sets", "the", "number", "of", "parallel", "network", "backend", "connections", "to", "send", "spans", "with", ".", "Each", "backend", "holds", "a", "connection", "to", "an", "SSF", "receiver", "open", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L278-L286
13,470
stripe/veneur
trace/client.go
NewChannelClient
func NewChannelClient(spanChan chan<- *ssf.SSFSpan, opts ...ClientParam) (*Client, error) { cl := &Client{} cl.flushBackends = []flushNotifier{} cl.spans = spanChan for _, opt := range opts { if err := opt(cl); err != nil { return nil, err } } ctx := context.Background() ctx, cl.cancel = context.WithCan...
go
func NewChannelClient(spanChan chan<- *ssf.SSFSpan, opts ...ClientParam) (*Client, error) { cl := &Client{} cl.flushBackends = []flushNotifier{} cl.spans = spanChan for _, opt := range opts { if err := opt(cl); err != nil { return nil, err } } ctx := context.Background() ctx, cl.cancel = context.WithCan...
[ "func", "NewChannelClient", "(", "spanChan", "chan", "<-", "*", "ssf", ".", "SSFSpan", ",", "opts", "...", "ClientParam", ")", "(", "*", "Client", ",", "error", ")", "{", "cl", ":=", "&", "Client", "{", "}", "\n", "cl", ".", "flushBackends", "=", "["...
// NewChannelClient constructs and returns a Client that can send // directly into a span receiver channel. It provides an alternative // interface to NewBackendClient for constructing internal and // test-only clients.
[ "NewChannelClient", "constructs", "and", "returns", "a", "Client", "that", "can", "send", "directly", "into", "a", "span", "receiver", "channel", ".", "It", "provides", "an", "alternative", "interface", "to", "NewBackendClient", "for", "constructing", "internal", ...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L372-L388
13,471
stripe/veneur
trace/client.go
SetDefaultClient
func SetDefaultClient(client *Client) { oldClient := DefaultClient DefaultClient = client // Ensure the old client is closed so it does not leak connections if oldClient != nil { oldClient.Close() } }
go
func SetDefaultClient(client *Client) { oldClient := DefaultClient DefaultClient = client // Ensure the old client is closed so it does not leak connections if oldClient != nil { oldClient.Close() } }
[ "func", "SetDefaultClient", "(", "client", "*", "Client", ")", "{", "oldClient", ":=", "DefaultClient", "\n", "DefaultClient", "=", "client", "\n\n", "// Ensure the old client is closed so it does not leak connections", "if", "oldClient", "!=", "nil", "{", "oldClient", ...
// SetDefaultClient overrides the default client used for recording // traces, and gracefully closes the existing one. // This is not safe to run concurrently with other goroutines.
[ "SetDefaultClient", "overrides", "the", "default", "client", "used", "for", "recording", "traces", "and", "gracefully", "closes", "the", "existing", "one", ".", "This", "is", "not", "safe", "to", "run", "concurrently", "with", "other", "goroutines", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L393-L401
13,472
stripe/veneur
trace/client.go
NeutralizeClient
func NeutralizeClient(client *Client) { client.Close() client.records = nil client.spans = nil client.flushBackends = []flushNotifier{} }
go
func NeutralizeClient(client *Client) { client.Close() client.records = nil client.spans = nil client.flushBackends = []flushNotifier{} }
[ "func", "NeutralizeClient", "(", "client", "*", "Client", ")", "{", "client", ".", "Close", "(", ")", "\n", "client", ".", "records", "=", "nil", "\n", "client", ".", "spans", "=", "nil", "\n", "client", ".", "flushBackends", "=", "[", "]", "flushNotif...
// NeutralizeClient sets up a client such that all Record or Flush // operations result in ErrWouldBlock. It dashes all hope of a Client // ever successfully recording or flushing spans, and is mostly useful // in tests.
[ "NeutralizeClient", "sets", "up", "a", "client", "such", "that", "all", "Record", "or", "Flush", "operations", "result", "in", "ErrWouldBlock", ".", "It", "dashes", "all", "hope", "of", "a", "Client", "ever", "successfully", "recording", "or", "flushing", "spa...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L407-L412
13,473
stripe/veneur
trace/client.go
Record
func Record(cl *Client, span *ssf.SSFSpan, done chan<- error) error { if cl == nil { return ErrNoClient } op := &recordOp{span: span, result: done} select { case cl.spans <- span: atomic.AddInt64(&cl.successfulRecords, 1) if done != nil { go func() { done <- nil }() } return nil case cl.records <- o...
go
func Record(cl *Client, span *ssf.SSFSpan, done chan<- error) error { if cl == nil { return ErrNoClient } op := &recordOp{span: span, result: done} select { case cl.spans <- span: atomic.AddInt64(&cl.successfulRecords, 1) if done != nil { go func() { done <- nil }() } return nil case cl.records <- o...
[ "func", "Record", "(", "cl", "*", "Client", ",", "span", "*", "ssf", ".", "SSFSpan", ",", "done", "chan", "<-", "error", ")", "error", "{", "if", "cl", "==", "nil", "{", "return", "ErrNoClient", "\n", "}", "\n\n", "op", ":=", "&", "recordOp", "{", ...
// Record instructs the client to serialize and send a span. It does // not wait for a delivery attempt, instead the Client will send the // result from serializing and submitting the span to the channel // done, if it is non-nil. // // Record returns ErrNoClient if client is nil and ErrWouldBlock if // the client is n...
[ "Record", "instructs", "the", "client", "to", "serialize", "and", "send", "a", "span", ".", "It", "does", "not", "wait", "for", "a", "delivery", "attempt", "instead", "the", "Client", "will", "send", "the", "result", "from", "serializing", "and", "submitting...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/trace/client.go#L469-L489
13,474
stripe/veneur
tdigest/merging_digest.go
NewMerging
func NewMerging(compression float64, debug bool) *MergingDigest { // this is a provable upper bound on the size of the centroid list // TODO: derive it myself sizeBound := int((math.Pi * compression / 2) + 0.5) return &MergingDigest{ compression: compression, mainCentroids: make([]Centroid, 0, sizeBound), ...
go
func NewMerging(compression float64, debug bool) *MergingDigest { // this is a provable upper bound on the size of the centroid list // TODO: derive it myself sizeBound := int((math.Pi * compression / 2) + 0.5) return &MergingDigest{ compression: compression, mainCentroids: make([]Centroid, 0, sizeBound), ...
[ "func", "NewMerging", "(", "compression", "float64", ",", "debug", "bool", ")", "*", "MergingDigest", "{", "// this is a provable upper bound on the size of the centroid list", "// TODO: derive it myself", "sizeBound", ":=", "int", "(", "(", "math", ".", "Pi", "*", "com...
// Initializes a new merging t-digest using the given compression parameter. // Lower compression values result in reduced memory consumption and less // precision, especially at the median. Values from 20 to 1000 are recommended // in Dunning's paper. // // The debug flag adds a list to each centroid, which stores all...
[ "Initializes", "a", "new", "merging", "t", "-", "digest", "using", "the", "given", "compression", "parameter", ".", "Lower", "compression", "values", "result", "in", "reduced", "memory", "consumption", "and", "less", "precision", "especially", "at", "the", "medi...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L68-L81
13,475
stripe/veneur
tdigest/merging_digest.go
NewMergingFromData
func NewMergingFromData(d *MergingDigestData) *MergingDigest { td := &MergingDigest{ compression: d.Compression, mainCentroids: d.MainCentroids, tempCentroids: make([]Centroid, 0, estimateTempBuffer(d.Compression)), min: d.Min, max: d.Max, reciprocalSum: d.ReciprocalSum, } // Initi...
go
func NewMergingFromData(d *MergingDigestData) *MergingDigest { td := &MergingDigest{ compression: d.Compression, mainCentroids: d.MainCentroids, tempCentroids: make([]Centroid, 0, estimateTempBuffer(d.Compression)), min: d.Min, max: d.Max, reciprocalSum: d.ReciprocalSum, } // Initi...
[ "func", "NewMergingFromData", "(", "d", "*", "MergingDigestData", ")", "*", "MergingDigest", "{", "td", ":=", "&", "MergingDigest", "{", "compression", ":", "d", ".", "Compression", ",", "mainCentroids", ":", "d", ".", "MainCentroids", ",", "tempCentroids", ":...
// NewMergingFromData returns a MergingDigest with values initialized from // MergingDigestData. This should be the way to generate a MergingDigest // from a serialized protobuf.
[ "NewMergingFromData", "returns", "a", "MergingDigest", "with", "values", "initialized", "from", "MergingDigestData", ".", "This", "should", "be", "the", "way", "to", "generate", "a", "MergingDigest", "from", "a", "serialized", "protobuf", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L86-L103
13,476
stripe/veneur
tdigest/merging_digest.go
Add
func (td *MergingDigest) Add(value float64, weight float64) { if math.IsNaN(value) || math.IsInf(value, 0) || weight <= 0 { panic("invalid value added") } if len(td.tempCentroids) == cap(td.tempCentroids) { td.mergeAllTemps() } td.min = math.Min(td.min, value) td.max = math.Max(td.max, value) td.reciprocal...
go
func (td *MergingDigest) Add(value float64, weight float64) { if math.IsNaN(value) || math.IsInf(value, 0) || weight <= 0 { panic("invalid value added") } if len(td.tempCentroids) == cap(td.tempCentroids) { td.mergeAllTemps() } td.min = math.Min(td.min, value) td.max = math.Max(td.max, value) td.reciprocal...
[ "func", "(", "td", "*", "MergingDigest", ")", "Add", "(", "value", "float64", ",", "weight", "float64", ")", "{", "if", "math", ".", "IsNaN", "(", "value", ")", "||", "math", ".", "IsInf", "(", "value", ",", "0", ")", "||", "weight", "<=", "0", "...
// Adds a new value to the t-digest, with a given weight that must be positive. // Infinities and NaN cannot be added.
[ "Adds", "a", "new", "value", "to", "the", "t", "-", "digest", "with", "a", "given", "weight", "that", "must", "be", "positive", ".", "Infinities", "and", "NaN", "cannot", "be", "added", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L115-L137
13,477
stripe/veneur
tdigest/merging_digest.go
mergeAllTemps
func (td *MergingDigest) mergeAllTemps() { // this optimization is really important! if you remove it, the main list // will get merged into itself every time this is called if len(td.tempCentroids) == 0 { return } // we iterate over both centroid lists from least to greatest mean, so first // we have to sort ...
go
func (td *MergingDigest) mergeAllTemps() { // this optimization is really important! if you remove it, the main list // will get merged into itself every time this is called if len(td.tempCentroids) == 0 { return } // we iterate over both centroid lists from least to greatest mean, so first // we have to sort ...
[ "func", "(", "td", "*", "MergingDigest", ")", "mergeAllTemps", "(", ")", "{", "// this optimization is really important! if you remove it, the main list", "// will get merged into itself every time this is called", "if", "len", "(", "td", ".", "tempCentroids", ")", "==", "0",...
// combine the mainCentroids and tempCentroids in-place into mainCentroids
[ "combine", "the", "mainCentroids", "and", "tempCentroids", "in", "-", "place", "into", "mainCentroids" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L140-L224
13,478
stripe/veneur
tdigest/merging_digest.go
indexEstimate
func (td *MergingDigest) indexEstimate(quantile float64) float64 { // TODO: a polynomial approximation of arcsine should be a lot faster return td.compression * ((math.Asin(2*quantile-1) / math.Pi) + 0.5) }
go
func (td *MergingDigest) indexEstimate(quantile float64) float64 { // TODO: a polynomial approximation of arcsine should be a lot faster return td.compression * ((math.Asin(2*quantile-1) / math.Pi) + 0.5) }
[ "func", "(", "td", "*", "MergingDigest", ")", "indexEstimate", "(", "quantile", "float64", ")", "float64", "{", "// TODO: a polynomial approximation of arcsine should be a lot faster", "return", "td", ".", "compression", "*", "(", "(", "math", ".", "Asin", "(", "2",...
// given a quantile, estimate the index of the centroid that contains it using // the given compression
[ "given", "a", "quantile", "estimate", "the", "index", "of", "the", "centroid", "that", "contains", "it", "using", "the", "given", "compression" ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L259-L262
13,479
stripe/veneur
tdigest/merging_digest.go
Quantile
func (td *MergingDigest) Quantile(quantile float64) float64 { if quantile < 0 || quantile > 1 { panic("quantile out of bounds") } td.mergeAllTemps() // add up the weights of centroids in ascending order until we reach a // centroid that pushes us over the quantile q := quantile * td.mainWeight weightSoFar := ...
go
func (td *MergingDigest) Quantile(quantile float64) float64 { if quantile < 0 || quantile > 1 { panic("quantile out of bounds") } td.mergeAllTemps() // add up the weights of centroids in ascending order until we reach a // centroid that pushes us over the quantile q := quantile * td.mainWeight weightSoFar := ...
[ "func", "(", "td", "*", "MergingDigest", ")", "Quantile", "(", "quantile", "float64", ")", "float64", "{", "if", "quantile", "<", "0", "||", "quantile", ">", "1", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "td", ".", "mergeAllTemps", "(", ...
// Returns a value such that the fraction of values in td below that value is // approximately equal to quantile. Returns NaN if the digest is empty.
[ "Returns", "a", "value", "such", "that", "the", "fraction", "of", "values", "in", "td", "below", "that", "value", "is", "approximately", "equal", "to", "quantile", ".", "Returns", "NaN", "if", "the", "digest", "is", "empty", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L302-L332
13,480
stripe/veneur
tdigest/merging_digest.go
Merge
func (td *MergingDigest) Merge(other *MergingDigest) { oldReciprocalSum := td.reciprocalSum shuffledIndices := rand.Perm(len(other.mainCentroids)) for _, i := range shuffledIndices { td.Add(other.mainCentroids[i].Mean, other.mainCentroids[i].Weight) } // we did not merge other's temps, so we need to add those ...
go
func (td *MergingDigest) Merge(other *MergingDigest) { oldReciprocalSum := td.reciprocalSum shuffledIndices := rand.Perm(len(other.mainCentroids)) for _, i := range shuffledIndices { td.Add(other.mainCentroids[i].Mean, other.mainCentroids[i].Weight) } // we did not merge other's temps, so we need to add those ...
[ "func", "(", "td", "*", "MergingDigest", ")", "Merge", "(", "other", "*", "MergingDigest", ")", "{", "oldReciprocalSum", ":=", "td", ".", "reciprocalSum", "\n", "shuffledIndices", ":=", "rand", ".", "Perm", "(", "len", "(", "other", ".", "mainCentroids", "...
// Merge another digest into this one. Neither td nor other can be shared // concurrently during the execution of this method.
[ "Merge", "another", "digest", "into", "this", "one", ".", "Neither", "td", "nor", "other", "can", "be", "shared", "concurrently", "during", "the", "execution", "of", "this", "method", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L374-L389
13,481
stripe/veneur
tdigest/merging_digest.go
Centroids
func (td *MergingDigest) Centroids() []Centroid { if !td.debug { panic("must enable debug to call Centroids()") } td.mergeAllTemps() return td.mainCentroids }
go
func (td *MergingDigest) Centroids() []Centroid { if !td.debug { panic("must enable debug to call Centroids()") } td.mergeAllTemps() return td.mainCentroids }
[ "func", "(", "td", "*", "MergingDigest", ")", "Centroids", "(", ")", "[", "]", "Centroid", "{", "if", "!", "td", ".", "debug", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "td", ".", "mergeAllTemps", "(", ")", "\n", "return", "td", ".", ...
// This function provides direct access to the internal list of centroids in // this t-digest. Having access to this list is very important for analyzing the // t-digest's statistical properties. However, since it violates the encapsulation // of the t-digest, it should be used sparingly. Mutating the returned slice ca...
[ "This", "function", "provides", "direct", "access", "to", "the", "internal", "list", "of", "centroids", "in", "this", "t", "-", "digest", ".", "Having", "access", "to", "this", "list", "is", "very", "important", "for", "analyzing", "the", "t", "-", "digest...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/tdigest/merging_digest.go#L463-L469
13,482
stripe/veneur
flusher.go
tallyMetrics
func (s *Server) tallyMetrics(percentiles []float64) ([]WorkerMetrics, metricsSummary) { // allocating this long array to count up the sizes is cheaper than appending // the []WorkerMetrics together one at a time tempMetrics := make([]WorkerMetrics, 0, len(s.Workers)) ms := metricsSummary{} for i, w := range s.W...
go
func (s *Server) tallyMetrics(percentiles []float64) ([]WorkerMetrics, metricsSummary) { // allocating this long array to count up the sizes is cheaper than appending // the []WorkerMetrics together one at a time tempMetrics := make([]WorkerMetrics, 0, len(s.Workers)) ms := metricsSummary{} for i, w := range s.W...
[ "func", "(", "s", "*", "Server", ")", "tallyMetrics", "(", "percentiles", "[", "]", "float64", ")", "(", "[", "]", "WorkerMetrics", ",", "metricsSummary", ")", "{", "// allocating this long array to count up the sizes is cheaper than appending", "// the []WorkerMetrics to...
// tallyMetrics gives a slight overestimate of the number // of metrics we'll be reporting, so that we can pre-allocate // a slice of the correct length instead of constantly appending // for performance
[ "tallyMetrics", "gives", "a", "slight", "overestimate", "of", "the", "number", "of", "metrics", "we", "ll", "be", "reporting", "so", "that", "we", "can", "pre", "-", "allocate", "a", "slice", "of", "the", "correct", "length", "instead", "of", "constantly", ...
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/flusher.go#L153-L204
13,483
stripe/veneur
flusher.go
forwardGRPC
func (s *Server) forwardGRPC(ctx context.Context, wms []WorkerMetrics) { span, _ := trace.StartSpanFromContext(ctx, "") span.SetTag("protocol", "grpc") defer span.ClientFinish(s.TraceClient) exportStart := time.Now() // Collect all of the forwardable metrics from the various WorkerMetrics. var metrics []*metric...
go
func (s *Server) forwardGRPC(ctx context.Context, wms []WorkerMetrics) { span, _ := trace.StartSpanFromContext(ctx, "") span.SetTag("protocol", "grpc") defer span.ClientFinish(s.TraceClient) exportStart := time.Now() // Collect all of the forwardable metrics from the various WorkerMetrics. var metrics []*metric...
[ "func", "(", "s", "*", "Server", ")", "forwardGRPC", "(", "ctx", "context", ".", "Context", ",", "wms", "[", "]", "WorkerMetrics", ")", "{", "span", ",", "_", ":=", "trace", ".", "StartSpanFromContext", "(", "ctx", ",", "\"", "\"", ")", "\n", "span",...
// forwardGRPC forwards all input metrics to a downstream Veneur, over gRPC.
[ "forwardGRPC", "forwards", "all", "input", "metrics", "to", "a", "downstream", "Veneur", "over", "gRPC", "." ]
748a3593cd11cfb4543fbe3a3a3b1614a393e3a7
https://github.com/stripe/veneur/blob/748a3593cd11cfb4543fbe3a3a3b1614a393e3a7/flusher.go#L458-L518
13,484
moovweb/gokogiri
xpath/xpath.go
EvaluateAsNodeset
func (xpath *XPath) EvaluateAsNodeset(nodePtr unsafe.Pointer, xpathExpr *Expression) (nodes []unsafe.Pointer, err error) { if nodePtr == nil { //evaluating xpath on a nil node returns no result. return } err = xpath.Evaluate(nodePtr, xpathExpr) if err != nil { return } nodes, err = xpath.ResultAsNodeset(...
go
func (xpath *XPath) EvaluateAsNodeset(nodePtr unsafe.Pointer, xpathExpr *Expression) (nodes []unsafe.Pointer, err error) { if nodePtr == nil { //evaluating xpath on a nil node returns no result. return } err = xpath.Evaluate(nodePtr, xpathExpr) if err != nil { return } nodes, err = xpath.ResultAsNodeset(...
[ "func", "(", "xpath", "*", "XPath", ")", "EvaluateAsNodeset", "(", "nodePtr", "unsafe", ".", "Pointer", ",", "xpathExpr", "*", "Expression", ")", "(", "nodes", "[", "]", "unsafe", ".", "Pointer", ",", "err", "error", ")", "{", "if", "nodePtr", "==", "n...
// Evaluate an XPath and attempt to consume the result as a nodeset.
[ "Evaluate", "an", "XPath", "and", "attempt", "to", "consume", "the", "result", "as", "a", "nodeset", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xpath/xpath.go#L107-L120
13,485
moovweb/gokogiri
xpath/xpath.go
ResultAsNodeset
func (xpath *XPath) ResultAsNodeset() (nodes []unsafe.Pointer, err error) { if xpath.ResultPtr == nil { return } if xpath.ReturnType() != XPATH_NODESET { err = errors.New("Cannot convert XPath result to nodeset") } if nodesetPtr := xpath.ResultPtr.nodesetval; nodesetPtr != nil { if nodesetSize := int(nodes...
go
func (xpath *XPath) ResultAsNodeset() (nodes []unsafe.Pointer, err error) { if xpath.ResultPtr == nil { return } if xpath.ReturnType() != XPATH_NODESET { err = errors.New("Cannot convert XPath result to nodeset") } if nodesetPtr := xpath.ResultPtr.nodesetval; nodesetPtr != nil { if nodesetSize := int(nodes...
[ "func", "(", "xpath", "*", "XPath", ")", "ResultAsNodeset", "(", ")", "(", "nodes", "[", "]", "unsafe", ".", "Pointer", ",", "err", "error", ")", "{", "if", "xpath", ".", "ResultPtr", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "xpath", "....
// Get the XPath result as a nodeset.
[ "Get", "the", "XPath", "result", "as", "a", "nodeset", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xpath/xpath.go#L164-L182
13,486
moovweb/gokogiri
xpath/xpath.go
ResultAsString
func (xpath *XPath) ResultAsString() (val string, err error) { if xpath.ReturnType() != XPATH_STRING { xpath.ResultPtr = C.xmlXPathConvertString(xpath.ResultPtr) } val = C.GoString((*C.char)(unsafe.Pointer(xpath.ResultPtr.stringval))) return }
go
func (xpath *XPath) ResultAsString() (val string, err error) { if xpath.ReturnType() != XPATH_STRING { xpath.ResultPtr = C.xmlXPathConvertString(xpath.ResultPtr) } val = C.GoString((*C.char)(unsafe.Pointer(xpath.ResultPtr.stringval))) return }
[ "func", "(", "xpath", "*", "XPath", ")", "ResultAsString", "(", ")", "(", "val", "string", ",", "err", "error", ")", "{", "if", "xpath", ".", "ReturnType", "(", ")", "!=", "XPATH_STRING", "{", "xpath", ".", "ResultPtr", "=", "C", ".", "xmlXPathConvertS...
// Coerce the result into a string
[ "Coerce", "the", "result", "into", "a", "string" ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xpath/xpath.go#L185-L191
13,487
moovweb/gokogiri
xpath/xpath.go
ResultAsNumber
func (xpath *XPath) ResultAsNumber() (val float64, err error) { if xpath.ReturnType() != XPATH_NUMBER { xpath.ResultPtr = C.xmlXPathConvertNumber(xpath.ResultPtr) } val = float64(xpath.ResultPtr.floatval) return }
go
func (xpath *XPath) ResultAsNumber() (val float64, err error) { if xpath.ReturnType() != XPATH_NUMBER { xpath.ResultPtr = C.xmlXPathConvertNumber(xpath.ResultPtr) } val = float64(xpath.ResultPtr.floatval) return }
[ "func", "(", "xpath", "*", "XPath", ")", "ResultAsNumber", "(", ")", "(", "val", "float64", ",", "err", "error", ")", "{", "if", "xpath", ".", "ReturnType", "(", ")", "!=", "XPATH_NUMBER", "{", "xpath", ".", "ResultPtr", "=", "C", ".", "xmlXPathConvert...
// Coerce the result into a number
[ "Coerce", "the", "result", "into", "a", "number" ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xpath/xpath.go#L194-L200
13,488
moovweb/gokogiri
xpath/xpath.go
ResultAsBoolean
func (xpath *XPath) ResultAsBoolean() (val bool, err error) { xpath.ResultPtr = C.xmlXPathConvertBoolean(xpath.ResultPtr) val = xpath.ResultPtr.boolval != 0 return }
go
func (xpath *XPath) ResultAsBoolean() (val bool, err error) { xpath.ResultPtr = C.xmlXPathConvertBoolean(xpath.ResultPtr) val = xpath.ResultPtr.boolval != 0 return }
[ "func", "(", "xpath", "*", "XPath", ")", "ResultAsBoolean", "(", ")", "(", "val", "bool", ",", "err", "error", ")", "{", "xpath", ".", "ResultPtr", "=", "C", ".", "xmlXPathConvertBoolean", "(", "xpath", ".", "ResultPtr", ")", "\n", "val", "=", "xpath",...
// Coerce the result into a boolean
[ "Coerce", "the", "result", "into", "a", "boolean" ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xpath/xpath.go#L203-L207
13,489
moovweb/gokogiri
xpath/xpath.go
SetResolver
func (xpath *XPath) SetResolver(v VariableScope) { C.set_var_lookup(xpath.ContextPtr, unsafe.Pointer(&v)) C.set_function_lookup(xpath.ContextPtr, unsafe.Pointer(&v)) }
go
func (xpath *XPath) SetResolver(v VariableScope) { C.set_var_lookup(xpath.ContextPtr, unsafe.Pointer(&v)) C.set_function_lookup(xpath.ContextPtr, unsafe.Pointer(&v)) }
[ "func", "(", "xpath", "*", "XPath", ")", "SetResolver", "(", "v", "VariableScope", ")", "{", "C", ".", "set_var_lookup", "(", "xpath", ".", "ContextPtr", ",", "unsafe", ".", "Pointer", "(", "&", "v", ")", ")", "\n", "C", ".", "set_function_lookup", "("...
// Add a variable resolver.
[ "Add", "a", "variable", "resolver", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xpath/xpath.go#L210-L213
13,490
moovweb/gokogiri
xml/node.go
NewNode
func NewNode(nodePtr unsafe.Pointer, document Document) (node Node) { if nodePtr == nil { return nil } xmlNode := &XmlNode{ Ptr: (*C.xmlNode)(nodePtr), Document: document, valid: true, } nodeType := NodeType(C.getNodeType((*C.xmlNode)(nodePtr))) switch nodeType { default: node = xmlNode case ...
go
func NewNode(nodePtr unsafe.Pointer, document Document) (node Node) { if nodePtr == nil { return nil } xmlNode := &XmlNode{ Ptr: (*C.xmlNode)(nodePtr), Document: document, valid: true, } nodeType := NodeType(C.getNodeType((*C.xmlNode)(nodePtr))) switch nodeType { default: node = xmlNode case ...
[ "func", "NewNode", "(", "nodePtr", "unsafe", ".", "Pointer", ",", "document", "Document", ")", "(", "node", "Node", ")", "{", "if", "nodePtr", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "xmlNode", ":=", "&", "XmlNode", "{", "Ptr", ":", "(", ...
// NewNode takes a C pointer from the libxml2 library and returns a Node instance of // the appropriate type.
[ "NewNode", "takes", "a", "C", "pointer", "from", "the", "libxml2", "library", "and", "returns", "a", "Node", "instance", "of", "the", "appropriate", "type", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L170-L198
13,491
moovweb/gokogiri
xml/node.go
AddChild
func (xmlNode *XmlNode) AddChild(data interface{}) (err error) { switch t := data.(type) { default: if nodes, err := xmlNode.coerce(data); err == nil { for _, node := range nodes { if err = xmlNode.addChild(node); err != nil { break } } } case *DocumentFragment: if nodes, err := xmlNode.coer...
go
func (xmlNode *XmlNode) AddChild(data interface{}) (err error) { switch t := data.(type) { default: if nodes, err := xmlNode.coerce(data); err == nil { for _, node := range nodes { if err = xmlNode.addChild(node); err != nil { break } } } case *DocumentFragment: if nodes, err := xmlNode.coer...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "AddChild", "(", "data", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "switch", "t", ":=", "data", ".", "(", "type", ")", "{", "default", ":", "if", "nodes", ",", "err", ":=", "xmlNode", ...
// Add a node as a child of the current node. // Passing in a nodeset will add all the nodes as children of the current node.
[ "Add", "a", "node", "as", "a", "child", "of", "the", "current", "node", ".", "Passing", "in", "a", "nodeset", "will", "add", "all", "the", "nodes", "as", "children", "of", "the", "current", "node", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L228-L250
13,492
moovweb/gokogiri
xml/node.go
AddPreviousSibling
func (xmlNode *XmlNode) AddPreviousSibling(data interface{}) (err error) { switch t := data.(type) { default: if nodes, err := xmlNode.coerce(data); err == nil { for _, node := range nodes { if err = xmlNode.addPreviousSibling(node); err != nil { break } } } case *DocumentFragment: if nodes,...
go
func (xmlNode *XmlNode) AddPreviousSibling(data interface{}) (err error) { switch t := data.(type) { default: if nodes, err := xmlNode.coerce(data); err == nil { for _, node := range nodes { if err = xmlNode.addPreviousSibling(node); err != nil { break } } } case *DocumentFragment: if nodes,...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "AddPreviousSibling", "(", "data", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "switch", "t", ":=", "data", ".", "(", "type", ")", "{", "default", ":", "if", "nodes", ",", "err", ":=", "xm...
// Insert a node immediately before this node in the document. // Passing in a nodeset will add all the nodes, in order.
[ "Insert", "a", "node", "immediately", "before", "this", "node", "in", "the", "document", ".", "Passing", "in", "a", "nodeset", "will", "add", "all", "the", "nodes", "in", "order", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L254-L276
13,493
moovweb/gokogiri
xml/node.go
AddNextSibling
func (xmlNode *XmlNode) AddNextSibling(data interface{}) (err error) { switch t := data.(type) { default: if nodes, err := xmlNode.coerce(data); err == nil { for i := len(nodes) - 1; i >= 0; i-- { node := nodes[i] if err = xmlNode.addNextSibling(node); err != nil { break } } } case *Docume...
go
func (xmlNode *XmlNode) AddNextSibling(data interface{}) (err error) { switch t := data.(type) { default: if nodes, err := xmlNode.coerce(data); err == nil { for i := len(nodes) - 1; i >= 0; i-- { node := nodes[i] if err = xmlNode.addNextSibling(node); err != nil { break } } } case *Docume...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "AddNextSibling", "(", "data", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "switch", "t", ":=", "data", ".", "(", "type", ")", "{", "default", ":", "if", "nodes", ",", "err", ":=", "xmlNod...
// Insert a node immediately after this node in the document. // Passing in a nodeset will add all the nodes, in order.
[ "Insert", "a", "node", "immediately", "after", "this", "node", "in", "the", "document", ".", "Passing", "in", "a", "nodeset", "will", "add", "all", "the", "nodes", "in", "order", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L280-L304
13,494
moovweb/gokogiri
xml/node.go
NodePtr
func (xmlNode *XmlNode) NodePtr() (p unsafe.Pointer) { p = unsafe.Pointer(xmlNode.Ptr) return }
go
func (xmlNode *XmlNode) NodePtr() (p unsafe.Pointer) { p = unsafe.Pointer(xmlNode.Ptr) return }
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "NodePtr", "(", ")", "(", "p", "unsafe", ".", "Pointer", ")", "{", "p", "=", "unsafe", ".", "Pointer", "(", "xmlNode", ".", "Ptr", ")", "\n", "return", "\n", "}" ]
// NodePtr returns a pointer to the underlying C struct.
[ "NodePtr", "returns", "a", "pointer", "to", "the", "underlying", "C", "struct", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L325-L328
13,495
moovweb/gokogiri
xml/node.go
Path
func (xmlNode *XmlNode) Path() (path string) { pathPtr := C.xmlGetNodePath(xmlNode.Ptr) if pathPtr != nil { p := (*C.char)(unsafe.Pointer(pathPtr)) defer C.xmlFreeChars(p) path = C.GoString(p) } return }
go
func (xmlNode *XmlNode) Path() (path string) { pathPtr := C.xmlGetNodePath(xmlNode.Ptr) if pathPtr != nil { p := (*C.char)(unsafe.Pointer(pathPtr)) defer C.xmlFreeChars(p) path = C.GoString(p) } return }
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "Path", "(", ")", "(", "path", "string", ")", "{", "pathPtr", ":=", "C", ".", "xmlGetNodePath", "(", "xmlNode", ".", "Ptr", ")", "\n", "if", "pathPtr", "!=", "nil", "{", "p", ":=", "(", "*", "C", ".", ...
// Path returns an XPath expression that can be used to // select this node in the document.
[ "Path", "returns", "an", "XPath", "expression", "that", "can", "be", "used", "to", "select", "this", "node", "in", "the", "document", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L337-L345
13,496
moovweb/gokogiri
xml/node.go
Attribute
func (xmlNode *XmlNode) Attribute(name string) (attribute *AttributeNode) { if xmlNode.NodeType() != XML_ELEMENT_NODE { return } nameBytes := GetCString([]byte(name)) namePtr := unsafe.Pointer(&nameBytes[0]) attrPtr := C.xmlHasNsProp(xmlNode.Ptr, (*C.xmlChar)(namePtr), nil) if attrPtr == nil { return } else ...
go
func (xmlNode *XmlNode) Attribute(name string) (attribute *AttributeNode) { if xmlNode.NodeType() != XML_ELEMENT_NODE { return } nameBytes := GetCString([]byte(name)) namePtr := unsafe.Pointer(&nameBytes[0]) attrPtr := C.xmlHasNsProp(xmlNode.Ptr, (*C.xmlChar)(namePtr), nil) if attrPtr == nil { return } else ...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "Attribute", "(", "name", "string", ")", "(", "attribute", "*", "AttributeNode", ")", "{", "if", "xmlNode", ".", "NodeType", "(", ")", "!=", "XML_ELEMENT_NODE", "{", "return", "\n", "}", "\n", "nameBytes", ":=...
// Return the attribute node, or nil if the attribute does not exist.
[ "Return", "the", "attribute", "node", "or", "nil", "if", "the", "attribute", "does", "not", "exist", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L480-L496
13,497
moovweb/gokogiri
xml/node.go
Attr
func (xmlNode *XmlNode) Attr(name string) (val string) { if xmlNode.NodeType() != XML_ELEMENT_NODE { return } nameBytes := GetCString([]byte(name)) namePtr := unsafe.Pointer(&nameBytes[0]) valPtr := C.xmlGetProp(xmlNode.Ptr, (*C.xmlChar)(namePtr)) if valPtr == nil { return } p := unsafe.Pointer(valPtr) def...
go
func (xmlNode *XmlNode) Attr(name string) (val string) { if xmlNode.NodeType() != XML_ELEMENT_NODE { return } nameBytes := GetCString([]byte(name)) namePtr := unsafe.Pointer(&nameBytes[0]) valPtr := C.xmlGetProp(xmlNode.Ptr, (*C.xmlChar)(namePtr)) if valPtr == nil { return } p := unsafe.Pointer(valPtr) def...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "Attr", "(", "name", "string", ")", "(", "val", "string", ")", "{", "if", "xmlNode", ".", "NodeType", "(", ")", "!=", "XML_ELEMENT_NODE", "{", "return", "\n", "}", "\n", "nameBytes", ":=", "GetCString", "(",...
// Attr returns the value of an attribute. // If you need to check for the existence of an attribute, // use Attribute.
[ "Attr", "returns", "the", "value", "of", "an", "attribute", ".", "If", "you", "need", "to", "check", "for", "the", "existence", "of", "an", "attribute", "use", "Attribute", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L502-L516
13,498
moovweb/gokogiri
xml/node.go
Search
func (xmlNode *XmlNode) Search(data interface{}) (result []Node, err error) { switch data := data.(type) { default: err = ERR_UNDEFINED_SEARCH_PARAM case string: if xpathExpr := xpath.Compile(data); xpathExpr != nil { defer xpathExpr.Free() result, err = xmlNode.Search(xpathExpr) } else { err = errors...
go
func (xmlNode *XmlNode) Search(data interface{}) (result []Node, err error) { switch data := data.(type) { default: err = ERR_UNDEFINED_SEARCH_PARAM case string: if xpathExpr := xpath.Compile(data); xpathExpr != nil { defer xpathExpr.Free() result, err = xmlNode.Search(xpathExpr) } else { err = errors...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "Search", "(", "data", "interface", "{", "}", ")", "(", "result", "[", "]", "Node", ",", "err", "error", ")", "{", "switch", "data", ":=", "data", ".", "(", "type", ")", "{", "default", ":", "err", "="...
// Search for nodes that match an XPath. This is the simplest way to look for nodes.
[ "Search", "for", "nodes", "that", "match", "an", "XPath", ".", "This", "is", "the", "simplest", "way", "to", "look", "for", "nodes", "." ]
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L572-L596
13,499
moovweb/gokogiri
xml/node.go
EvalXPathAsBoolean
func (xmlNode *XmlNode) EvalXPathAsBoolean(data interface{}, v xpath.VariableScope) (result bool) { switch data := data.(type) { case string: if xpathExpr := xpath.Compile(data); xpathExpr != nil { defer xpathExpr.Free() result = xmlNode.EvalXPathAsBoolean(xpathExpr, v) } else { //err = errors.New("canno...
go
func (xmlNode *XmlNode) EvalXPathAsBoolean(data interface{}, v xpath.VariableScope) (result bool) { switch data := data.(type) { case string: if xpathExpr := xpath.Compile(data); xpathExpr != nil { defer xpathExpr.Free() result = xmlNode.EvalXPathAsBoolean(xpathExpr, v) } else { //err = errors.New("canno...
[ "func", "(", "xmlNode", "*", "XmlNode", ")", "EvalXPathAsBoolean", "(", "data", "interface", "{", "}", ",", "v", "xpath", ".", "VariableScope", ")", "(", "result", "bool", ")", "{", "switch", "data", ":=", "data", ".", "(", "type", ")", "{", "case", ...
// Evaluate an XPath and coerce the result to a boolean according to the // XPath rules. In the presence of an error, this function will return false // even if the expression cannot actually be evaluated. // In most cases you are better advised to call EvalXPath; this function is // intended for packages that implemen...
[ "Evaluate", "an", "XPath", "and", "coerce", "the", "result", "to", "a", "boolean", "according", "to", "the", "XPath", "rules", ".", "In", "the", "presence", "of", "an", "error", "this", "function", "will", "return", "false", "even", "if", "the", "expressio...
a1a828153468a7518b184e698f6265904108d957
https://github.com/moovweb/gokogiri/blob/a1a828153468a7518b184e698f6265904108d957/xml/node.go#L691-L714