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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
140,700
signalfx/golib
ketama/ketama.go
Hash
func (c *Continuum) Hash(thing []byte) Bucket { hash := md5.Sum(thing) h := binary.LittleEndian.Uint32(hash[0:4]) return c.Bucket(h) }
go
func (c *Continuum) Hash(thing []byte) Bucket { hash := md5.Sum(thing) h := binary.LittleEndian.Uint32(hash[0:4]) return c.Bucket(h) }
[ "func", "(", "c", "*", "Continuum", ")", "Hash", "(", "thing", "[", "]", "byte", ")", "Bucket", "{", "hash", ":=", "md5", ".", "Sum", "(", "thing", ")", "\n\n", "h", ":=", "binary", ".", "LittleEndian", ".", "Uint32", "(", "hash", "[", "0", ":", ...
// Hash an array of bytes into a location in the ring
[ "Hash", "an", "array", "of", "bytes", "into", "a", "location", "in", "the", "ring" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/ketama/ketama.go#L101-L106
140,701
signalfx/golib
ketama/ketama.go
Bucket
func (c *Continuum) Bucket(ringLocation uint32) Bucket { if c == nil || len(c.ring) == 0 { return nil } i := uint(sort.Search(len(c.ring), func(i int) bool { return c.ring[i].point >= ringLocation })) if i >= uint(len(c.ring)) { i = 0 } return c.ring[i].bucket }
go
func (c *Continuum) Bucket(ringLocation uint32) Bucket { if c == nil || len(c.ring) == 0 { return nil } i := uint(sort.Search(len(c.ring), func(i int) bool { return c.ring[i].point >= ringLocation })) if i >= uint(len(c.ring)) { i = 0 } return c.ring[i].bucket }
[ "func", "(", "c", "*", "Continuum", ")", "Bucket", "(", "ringLocation", "uint32", ")", "Bucket", "{", "if", "c", "==", "nil", "||", "len", "(", "c", ".", "ring", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "i", ":=", "uint", "(", "so...
// Bucket returns the bucket at or after a location in the ring
[ "Bucket", "returns", "the", "bucket", "at", "or", "after", "a", "location", "in", "the", "ring" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/ketama/ketama.go#L109-L119
140,702
signalfx/golib
datapoint/dpsink/counter.go
Datapoints
func (c *Counter) Datapoints() []*datapoint.Datapoint { var dims map[string]string if c.DroppedReason != "" { dims = map[string]string{"reason": c.DroppedReason} } return []*datapoint.Datapoint{ sfxclient.Cumulative("total_process_errors", nil, atomic.LoadInt64(&c.TotalProcessErrors)), sfxclient.Cumulative("t...
go
func (c *Counter) Datapoints() []*datapoint.Datapoint { var dims map[string]string if c.DroppedReason != "" { dims = map[string]string{"reason": c.DroppedReason} } return []*datapoint.Datapoint{ sfxclient.Cumulative("total_process_errors", nil, atomic.LoadInt64(&c.TotalProcessErrors)), sfxclient.Cumulative("t...
[ "func", "(", "c", "*", "Counter", ")", "Datapoints", "(", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "var", "dims", "map", "[", "string", "]", "string", "\n", "if", "c", ".", "DroppedReason", "!=", "\"", "\"", "{", "dims", "=", "map", ...
// Datapoints returns counter stats
[ "Datapoints", "returns", "counter", "stats" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L38-L55
140,703
signalfx/golib
datapoint/dpsink/counter.go
AddDatapoints
func (c *Counter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { atomic.AddInt64(&c.TotalDatapoints, int64(len(points))) atomic.AddInt64(&c.TotalProcessCalls, 1) atomic.AddInt64(&c.CallsInFlight, 1) start := time.Now() err := next.AddDatapoints(ctx, points) atomic.AddInt64(&c...
go
func (c *Counter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { atomic.AddInt64(&c.TotalDatapoints, int64(len(points))) atomic.AddInt64(&c.TotalProcessCalls, 1) atomic.AddInt64(&c.CallsInFlight, 1) start := time.Now() err := next.AddDatapoints(ctx, points) atomic.AddInt64(&c...
[ "func", "(", "c", "*", "Counter", ")", "AddDatapoints", "(", "ctx", "context", ".", "Context", ",", "points", "[", "]", "*", "datapoint", ".", "Datapoint", ",", "next", "Sink", ")", "error", "{", "atomic", ".", "AddInt64", "(", "&", "c", ".", "TotalD...
// AddDatapoints will send points to the next sink and track points send to the next sink
[ "AddDatapoints", "will", "send", "points", "to", "the", "next", "sink", "and", "track", "points", "send", "to", "the", "next", "sink" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L70-L84
140,704
signalfx/golib
datapoint/dpsink/counter.go
AddEvents
func (c *Counter) AddEvents(ctx context.Context, events []*event.Event, next Sink) error { atomic.AddInt64(&c.TotalEvents, int64(len(events))) atomic.AddInt64(&c.TotalProcessCalls, 1) atomic.AddInt64(&c.CallsInFlight, 1) start := time.Now() err := next.AddEvents(ctx, events) atomic.AddInt64(&c.TotalProcessTimeNs,...
go
func (c *Counter) AddEvents(ctx context.Context, events []*event.Event, next Sink) error { atomic.AddInt64(&c.TotalEvents, int64(len(events))) atomic.AddInt64(&c.TotalProcessCalls, 1) atomic.AddInt64(&c.CallsInFlight, 1) start := time.Now() err := next.AddEvents(ctx, events) atomic.AddInt64(&c.TotalProcessTimeNs,...
[ "func", "(", "c", "*", "Counter", ")", "AddEvents", "(", "ctx", "context", ".", "Context", ",", "events", "[", "]", "*", "event", ".", "Event", ",", "next", "Sink", ")", "error", "{", "atomic", ".", "AddInt64", "(", "&", "c", ".", "TotalEvents", ",...
// AddEvents will send events to the next sink and track events sent to the next sink
[ "AddEvents", "will", "send", "events", "to", "the", "next", "sink", "and", "track", "events", "sent", "to", "the", "next", "sink" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L94-L108
140,705
signalfx/golib
datapoint/dpsink/counter.go
AddSpans
func (c *Counter) AddSpans(ctx context.Context, spans []*trace.Span, next trace.Sink) error { atomic.AddInt64(&c.TotalSpans, int64(len(spans))) atomic.AddInt64(&c.TotalProcessCalls, 1) atomic.AddInt64(&c.CallsInFlight, 1) start := time.Now() err := next.AddSpans(ctx, spans) atomic.AddInt64(&c.TotalProcessTimeNs, ...
go
func (c *Counter) AddSpans(ctx context.Context, spans []*trace.Span, next trace.Sink) error { atomic.AddInt64(&c.TotalSpans, int64(len(spans))) atomic.AddInt64(&c.TotalProcessCalls, 1) atomic.AddInt64(&c.CallsInFlight, 1) start := time.Now() err := next.AddSpans(ctx, spans) atomic.AddInt64(&c.TotalProcessTimeNs, ...
[ "func", "(", "c", "*", "Counter", ")", "AddSpans", "(", "ctx", "context", ".", "Context", ",", "spans", "[", "]", "*", "trace", ".", "Span", ",", "next", "trace", ".", "Sink", ")", "error", "{", "atomic", ".", "AddInt64", "(", "&", "c", ".", "Tot...
// AddSpans will send spans to the next sink and track spans sent to the next sink
[ "AddSpans", "will", "send", "spans", "to", "the", "next", "sink", "and", "track", "spans", "sent", "to", "the", "next", "sink" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L111-L125
140,706
signalfx/golib
datapoint/dpsink/counter.go
AddDatapoints
func (h *HistoCounter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { h.DatapointBucket.Add(float64(len(points))) return h.sink.AddDatapoints(ctx, points, next) }
go
func (h *HistoCounter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { h.DatapointBucket.Add(float64(len(points))) return h.sink.AddDatapoints(ctx, points, next) }
[ "func", "(", "h", "*", "HistoCounter", ")", "AddDatapoints", "(", "ctx", "context", ".", "Context", ",", "points", "[", "]", "*", "datapoint", ".", "Datapoint", ",", "next", "Sink", ")", "error", "{", "h", ".", "DatapointBucket", ".", "Add", "(", "floa...
// AddDatapoints sample length of slice and pass on
[ "AddDatapoints", "sample", "length", "of", "slice", "and", "pass", "on" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L136-L139
140,707
signalfx/golib
datapoint/dpsink/counter.go
AddEvents
func (h *HistoCounter) AddEvents(ctx context.Context, events []*event.Event, next Sink) error { h.EventBucket.Add(float64(len(events))) return h.sink.AddEvents(ctx, events, next) }
go
func (h *HistoCounter) AddEvents(ctx context.Context, events []*event.Event, next Sink) error { h.EventBucket.Add(float64(len(events))) return h.sink.AddEvents(ctx, events, next) }
[ "func", "(", "h", "*", "HistoCounter", ")", "AddEvents", "(", "ctx", "context", ".", "Context", ",", "events", "[", "]", "*", "event", ".", "Event", ",", "next", "Sink", ")", "error", "{", "h", ".", "EventBucket", ".", "Add", "(", "float64", "(", "...
// AddEvents sample length of slice and pass on
[ "AddEvents", "sample", "length", "of", "slice", "and", "pass", "on" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L142-L145
140,708
signalfx/golib
datapoint/dpsink/counter.go
AddSpans
func (h *HistoCounter) AddSpans(ctx context.Context, spans []*trace.Span, next trace.Sink) error { h.SpanBucket.Add(float64(len(spans))) return h.sink.AddSpans(ctx, spans, next) }
go
func (h *HistoCounter) AddSpans(ctx context.Context, spans []*trace.Span, next trace.Sink) error { h.SpanBucket.Add(float64(len(spans))) return h.sink.AddSpans(ctx, spans, next) }
[ "func", "(", "h", "*", "HistoCounter", ")", "AddSpans", "(", "ctx", "context", ".", "Context", ",", "spans", "[", "]", "*", "trace", ".", "Span", ",", "next", "trace", ".", "Sink", ")", "error", "{", "h", ".", "SpanBucket", ".", "Add", "(", "float6...
// AddSpans sample length of slice and pass on
[ "AddSpans", "sample", "length", "of", "slice", "and", "pass", "on" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L148-L151
140,709
signalfx/golib
datapoint/dpsink/counter.go
Datapoints
func (h *HistoCounter) Datapoints() []*datapoint.Datapoint { dps := h.sink.Datapoints() dps = append(dps, h.DatapointBucket.Datapoints()...) dps = append(dps, h.EventBucket.Datapoints()...) dps = append(dps, h.SpanBucket.Datapoints()...) return dps }
go
func (h *HistoCounter) Datapoints() []*datapoint.Datapoint { dps := h.sink.Datapoints() dps = append(dps, h.DatapointBucket.Datapoints()...) dps = append(dps, h.EventBucket.Datapoints()...) dps = append(dps, h.SpanBucket.Datapoints()...) return dps }
[ "func", "(", "h", "*", "HistoCounter", ")", "Datapoints", "(", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "dps", ":=", "h", ".", "sink", ".", "Datapoints", "(", ")", "\n", "dps", "=", "append", "(", "dps", ",", "h", ".", "DatapointBuck...
// Datapoints is rather self explanitory
[ "Datapoints", "is", "rather", "self", "explanitory" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L154-L160
140,710
signalfx/golib
datapoint/dpsink/counter.go
NewHistoCounter
func NewHistoCounter(sink *Counter) *HistoCounter { return &HistoCounter{ sink: sink, DatapointBucket: sfxclient.NewRollingBucket("datapoint_batch_size", map[string]string{}), EventBucket: sfxclient.NewRollingBucket("event_batch_size", map[string]string{}), SpanBucket: sfxclient.NewRollingB...
go
func NewHistoCounter(sink *Counter) *HistoCounter { return &HistoCounter{ sink: sink, DatapointBucket: sfxclient.NewRollingBucket("datapoint_batch_size", map[string]string{}), EventBucket: sfxclient.NewRollingBucket("event_batch_size", map[string]string{}), SpanBucket: sfxclient.NewRollingB...
[ "func", "NewHistoCounter", "(", "sink", "*", "Counter", ")", "*", "HistoCounter", "{", "return", "&", "HistoCounter", "{", "sink", ":", "sink", ",", "DatapointBucket", ":", "sfxclient", ".", "NewRollingBucket", "(", "\"", "\"", ",", "map", "[", "string", "...
// NewHistoCounter is a constructor
[ "NewHistoCounter", "is", "a", "constructor" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/counter.go#L163-L170
140,711
signalfx/golib
log/json.go
NewJSONLogger
func NewJSONLogger(w io.Writer, ErrHandler ErrorHandler) Logger { if w == ioutil.Discard { return Discard } return &ErrorLogLogger{ RootLogger: &JSONLogger{ Out: w, MissingValueKey: Msg, }, ErrHandler: ErrHandler, } }
go
func NewJSONLogger(w io.Writer, ErrHandler ErrorHandler) Logger { if w == ioutil.Discard { return Discard } return &ErrorLogLogger{ RootLogger: &JSONLogger{ Out: w, MissingValueKey: Msg, }, ErrHandler: ErrHandler, } }
[ "func", "NewJSONLogger", "(", "w", "io", ".", "Writer", ",", "ErrHandler", "ErrorHandler", ")", "Logger", "{", "if", "w", "==", "ioutil", ".", "Discard", "{", "return", "Discard", "\n", "}", "\n", "return", "&", "ErrorLogLogger", "{", "RootLogger", ":", ...
// NewJSONLogger creates a new JSON logger
[ "NewJSONLogger", "creates", "a", "new", "JSON", "logger" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/json.go#L22-L33
140,712
signalfx/golib
log/json.go
Log
func (j *JSONLogger) Log(keyvals ...interface{}) error { m := mapFromKeyvals(j.MissingValueKey, keyvals...) return errors.Annotate(json.NewEncoder(j.Out).Encode(m), "cannot JSON encode log") }
go
func (j *JSONLogger) Log(keyvals ...interface{}) error { m := mapFromKeyvals(j.MissingValueKey, keyvals...) return errors.Annotate(json.NewEncoder(j.Out).Encode(m), "cannot JSON encode log") }
[ "func", "(", "j", "*", "JSONLogger", ")", "Log", "(", "keyvals", "...", "interface", "{", "}", ")", "error", "{", "m", ":=", "mapFromKeyvals", "(", "j", ".", "MissingValueKey", ",", "keyvals", "...", ")", "\n", "return", "errors", ".", "Annotate", "(",...
// Log will format a JSON map and write it to Out
[ "Log", "will", "format", "a", "JSON", "map", "and", "write", "it", "to", "Out" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/json.go#L36-L39
140,713
signalfx/golib
log/json.go
mapKey
func mapKey(k interface{}) (s string) { defer func() { if panicVal := recover(); panicVal != nil { s = nilCheck(k, panicVal, "NULL").(string) } }() switch x := k.(type) { case string: return x case fmt.Stringer: return x.String() default: return fmt.Sprint(x) } }
go
func mapKey(k interface{}) (s string) { defer func() { if panicVal := recover(); panicVal != nil { s = nilCheck(k, panicVal, "NULL").(string) } }() switch x := k.(type) { case string: return x case fmt.Stringer: return x.String() default: return fmt.Sprint(x) } }
[ "func", "mapKey", "(", "k", "interface", "{", "}", ")", "(", "s", "string", ")", "{", "defer", "func", "(", ")", "{", "if", "panicVal", ":=", "recover", "(", ")", ";", "panicVal", "!=", "nil", "{", "s", "=", "nilCheck", "(", "k", ",", "panicVal",...
// Different from go-kit. People just shouldn't pass nil values and should know if they do
[ "Different", "from", "go", "-", "kit", ".", "People", "just", "shouldn", "t", "pass", "nil", "values", "and", "should", "know", "if", "they", "do" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/json.go#L57-L71
140,714
signalfx/golib
zkplus/zkplus.go
Conn
func (s *StaticConnector) Conn() (zktest.ZkConnSupported, <-chan zk.Event, error) { return s.C, s.Ch, nil }
go
func (s *StaticConnector) Conn() (zktest.ZkConnSupported, <-chan zk.Event, error) { return s.C, s.Ch, nil }
[ "func", "(", "s", "*", "StaticConnector", ")", "Conn", "(", ")", "(", "zktest", ".", "ZkConnSupported", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "return", "s", ".", "C", ",", "s", ".", "Ch", ",", "nil", "\n", "}" ]
// Conn will just return the constructed connection and event channel
[ "Conn", "will", "just", "return", "the", "constructed", "connection", "and", "event", "channel" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/zkplus/zkplus.go#L37-L39
140,715
signalfx/golib
zkplus/zkplus.go
ChildrenW
func (z *ZkPlus) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error) { z.forPath(path).Log(logkey.ZkMethod, "ChildrenW") return z.blockOnConn().ChildrenW(z.realPath(path)) }
go
func (z *ZkPlus) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error) { z.forPath(path).Log(logkey.ZkMethod, "ChildrenW") return z.blockOnConn().ChildrenW(z.realPath(path)) }
[ "func", "(", "z", "*", "ZkPlus", ")", "ChildrenW", "(", "path", "string", ")", "(", "[", "]", "string", ",", "*", "zk", ".", "Stat", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "z", ".", "forPath", "(", "path", ")", ".", "L...
// ChildrenW is like children but also sets a watch
[ "ChildrenW", "is", "like", "children", "but", "also", "sets", "a", "watch" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/zkplus/zkplus.go#L221-L224
140,716
signalfx/golib
zkplus/zkplus.go
Delete
func (z *ZkPlus) Delete(path string, version int32) error { z.forPath(path).Log(logkey.ZkMethod, "Delete") return z.blockOnConn().Delete(z.realPath(path), version) }
go
func (z *ZkPlus) Delete(path string, version int32) error { z.forPath(path).Log(logkey.ZkMethod, "Delete") return z.blockOnConn().Delete(z.realPath(path), version) }
[ "func", "(", "z", "*", "ZkPlus", ")", "Delete", "(", "path", "string", ",", "version", "int32", ")", "error", "{", "z", ".", "forPath", "(", "path", ")", ".", "Log", "(", "logkey", ".", "ZkMethod", ",", "\"", "\"", ")", "\n", "return", "z", ".", ...
// Delete a Zk node
[ "Delete", "a", "Zk", "node" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/zkplus/zkplus.go#L227-L230
140,717
signalfx/golib
zkplus/zkplus.go
Create
func (z *ZkPlus) Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error) { z.forPath(path).Log(logkey.ZkMethod, "Create") p, err := z.blockOnConn().Create(z.realPath(path), data, flags, acl) if strings.HasPrefix(p, z.pathPrefix) && z.pathPrefix != "" { p = p[len(z.pathPrefix)+1:] } return p, ...
go
func (z *ZkPlus) Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error) { z.forPath(path).Log(logkey.ZkMethod, "Create") p, err := z.blockOnConn().Create(z.realPath(path), data, flags, acl) if strings.HasPrefix(p, z.pathPrefix) && z.pathPrefix != "" { p = p[len(z.pathPrefix)+1:] } return p, ...
[ "func", "(", "z", "*", "ZkPlus", ")", "Create", "(", "path", "string", ",", "data", "[", "]", "byte", ",", "flags", "int32", ",", "acl", "[", "]", "zk", ".", "ACL", ")", "(", "string", ",", "error", ")", "{", "z", ".", "forPath", "(", "path", ...
// Create a Zk node
[ "Create", "a", "Zk", "node" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/zkplus/zkplus.go#L233-L240
140,718
signalfx/golib
zkplus/zkplus.go
Set
func (z *ZkPlus) Set(path string, data []byte, version int32) (*zk.Stat, error) { z.forPath(path).Log(logkey.ZkMethod, "Set") return z.blockOnConn().Set(z.realPath(path), data, version) }
go
func (z *ZkPlus) Set(path string, data []byte, version int32) (*zk.Stat, error) { z.forPath(path).Log(logkey.ZkMethod, "Set") return z.blockOnConn().Set(z.realPath(path), data, version) }
[ "func", "(", "z", "*", "ZkPlus", ")", "Set", "(", "path", "string", ",", "data", "[", "]", "byte", ",", "version", "int32", ")", "(", "*", "zk", ".", "Stat", ",", "error", ")", "{", "z", ".", "forPath", "(", "path", ")", ".", "Log", "(", "log...
// Set the data of a zk node
[ "Set", "the", "data", "of", "a", "zk", "node" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/zkplus/zkplus.go#L243-L246
140,719
signalfx/golib
datapoint/dpsink/ratelimitlogger.go
AddDatapoints
func (e *RateLimitErrorLogging) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { err := next.AddDatapoints(ctx, points) e.throttleLog(err) return err }
go
func (e *RateLimitErrorLogging) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { err := next.AddDatapoints(ctx, points) e.throttleLog(err) return err }
[ "func", "(", "e", "*", "RateLimitErrorLogging", ")", "AddDatapoints", "(", "ctx", "context", ".", "Context", ",", "points", "[", "]", "*", "datapoint", ".", "Datapoint", ",", "next", "Sink", ")", "error", "{", "err", ":=", "next", ".", "AddDatapoints", "...
// AddDatapoints forwards points and will log any errors forwarding, but only one per LogThrottle // duration
[ "AddDatapoints", "forwards", "points", "and", "will", "log", "any", "errors", "forwarding", "but", "only", "one", "per", "LogThrottle", "duration" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/ratelimitlogger.go#L22-L26
140,720
signalfx/golib
datapoint/dpsink/ratelimitlogger.go
AddEvents
func (e *RateLimitErrorLogging) AddEvents(ctx context.Context, points []*event.Event, next Sink) error { err := next.AddEvents(ctx, points) e.throttleLog(err) return err }
go
func (e *RateLimitErrorLogging) AddEvents(ctx context.Context, points []*event.Event, next Sink) error { err := next.AddEvents(ctx, points) e.throttleLog(err) return err }
[ "func", "(", "e", "*", "RateLimitErrorLogging", ")", "AddEvents", "(", "ctx", "context", ".", "Context", ",", "points", "[", "]", "*", "event", ".", "Event", ",", "next", "Sink", ")", "error", "{", "err", ":=", "next", ".", "AddEvents", "(", "ctx", "...
// AddEvents forwards points and will log any errors forwarding, but only one per LogThrottle // duration
[ "AddEvents", "forwards", "points", "and", "will", "log", "any", "errors", "forwarding", "but", "only", "one", "per", "LogThrottle", "duration" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/ratelimitlogger.go#L44-L48
140,721
signalfx/golib
log/ctxdims.go
From
func (c *CtxDimensions) From(ctx context.Context) []interface{} { existing := ctx.Value(c) if existing == nil { return []interface{}{} } return existing.([]interface{}) }
go
func (c *CtxDimensions) From(ctx context.Context) []interface{} { existing := ctx.Value(c) if existing == nil { return []interface{}{} } return existing.([]interface{}) }
[ "func", "(", "c", "*", "CtxDimensions", ")", "From", "(", "ctx", "context", ".", "Context", ")", "[", "]", "interface", "{", "}", "{", "existing", ":=", "ctx", ".", "Value", "(", "c", ")", "\n", "if", "existing", "==", "nil", "{", "return", "[", ...
// From returns the dimensions currently set inside a context object
[ "From", "returns", "the", "dimensions", "currently", "set", "inside", "a", "context", "object" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/ctxdims.go#L10-L16
140,722
signalfx/golib
log/ctxdims.go
Append
func (c *CtxDimensions) Append(ctx context.Context, vals ...interface{}) context.Context { if len(vals) == 0 { return ctx } if len(vals)%2 != 0 { panic("Expected even number of values") } existing := c.From(ctx) newArr := make([]interface{}, 0, len(existing)+len(vals)) newArr = append(newArr, existing...) n...
go
func (c *CtxDimensions) Append(ctx context.Context, vals ...interface{}) context.Context { if len(vals) == 0 { return ctx } if len(vals)%2 != 0 { panic("Expected even number of values") } existing := c.From(ctx) newArr := make([]interface{}, 0, len(existing)+len(vals)) newArr = append(newArr, existing...) n...
[ "func", "(", "c", "*", "CtxDimensions", ")", "Append", "(", "ctx", "context", ".", "Context", ",", "vals", "...", "interface", "{", "}", ")", "context", ".", "Context", "{", "if", "len", "(", "vals", ")", "==", "0", "{", "return", "ctx", "\n", "}",...
// Append returns a new context that appends vals as dimensions for logging
[ "Append", "returns", "a", "new", "context", "that", "appends", "vals", "as", "dimensions", "for", "logging" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/ctxdims.go#L19-L31
140,723
signalfx/golib
log/ctxdims.go
With
func (c *CtxDimensions) With(ctx context.Context, log Logger) *Context { return NewContext(log).With(c.From(ctx)...) }
go
func (c *CtxDimensions) With(ctx context.Context, log Logger) *Context { return NewContext(log).With(c.From(ctx)...) }
[ "func", "(", "c", "*", "CtxDimensions", ")", "With", "(", "ctx", "context", ".", "Context", ",", "log", "Logger", ")", "*", "Context", "{", "return", "NewContext", "(", "log", ")", ".", "With", "(", "c", ".", "From", "(", "ctx", ")", "...", ")", ...
// With returns a new Context object that appends the dimensions inside ctx with the context logCtx
[ "With", "returns", "a", "new", "Context", "object", "that", "appends", "the", "dimensions", "inside", "ctx", "with", "the", "context", "logCtx" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/ctxdims.go#L34-L36
140,724
signalfx/golib
web/reqcounter.go
Datapoints
func (m *RequestCounter) Datapoints() []*datapoint.Datapoint { return []*datapoint.Datapoint{ sfxclient.Cumulative("total_connections", nil, atomic.LoadInt64(&m.TotalConnections)), sfxclient.Cumulative("total_time_ns", nil, atomic.LoadInt64(&m.TotalProcessingTimeNs)), sfxclient.Gauge("active_connections", nil, a...
go
func (m *RequestCounter) Datapoints() []*datapoint.Datapoint { return []*datapoint.Datapoint{ sfxclient.Cumulative("total_connections", nil, atomic.LoadInt64(&m.TotalConnections)), sfxclient.Cumulative("total_time_ns", nil, atomic.LoadInt64(&m.TotalProcessingTimeNs)), sfxclient.Gauge("active_connections", nil, a...
[ "func", "(", "m", "*", "RequestCounter", ")", "Datapoints", "(", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "return", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "sfxclient", ".", "Cumulative", "(", "\"", "\"", ",", "nil", ",", "a...
// Datapoints returns stats on total connections, active connections, and total processing time
[ "Datapoints", "returns", "stats", "on", "total", "connections", "active", "connections", "and", "total", "processing", "time" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/reqcounter.go#L41-L47
140,725
signalfx/golib
clientcfg/client.go
Load
func (c *ClientConfig) Load(d *distconf.Distconf) { c.SourceName = d.Str("signalfuse.sourceName", "") c.AuthToken = d.Str("sf.metrics.auth_token", "") c.Endpoint = d.Str("sf.metrics.statsendpoint", "") c.ReportingInterval = d.Duration("sf.metrics.report_interval", time.Second) c.TimeKeeper = timekeeper.RealTime{} ...
go
func (c *ClientConfig) Load(d *distconf.Distconf) { c.SourceName = d.Str("signalfuse.sourceName", "") c.AuthToken = d.Str("sf.metrics.auth_token", "") c.Endpoint = d.Str("sf.metrics.statsendpoint", "") c.ReportingInterval = d.Duration("sf.metrics.report_interval", time.Second) c.TimeKeeper = timekeeper.RealTime{} ...
[ "func", "(", "c", "*", "ClientConfig", ")", "Load", "(", "d", "*", "distconf", ".", "Distconf", ")", "{", "c", ".", "SourceName", "=", "d", ".", "Str", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "c", ".", "AuthToken", "=", "d", ".", "Str", ...
// Load the client config values from distconf
[ "Load", "the", "client", "config", "values", "from", "distconf" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L34-L42
140,726
signalfx/golib
clientcfg/client.go
DefaultDimensions
func DefaultDimensions(conf *ClientConfig) (map[string]string, error) { signalfuseSourceName := conf.SourceName.Get() if signalfuseSourceName != "" { return map[string]string{"sf_source": signalfuseSourceName}, nil } hostname, err := conf.OsHostname() if err != nil { return nil, errors.Annotate(err, "unable to...
go
func DefaultDimensions(conf *ClientConfig) (map[string]string, error) { signalfuseSourceName := conf.SourceName.Get() if signalfuseSourceName != "" { return map[string]string{"sf_source": signalfuseSourceName}, nil } hostname, err := conf.OsHostname() if err != nil { return nil, errors.Annotate(err, "unable to...
[ "func", "DefaultDimensions", "(", "conf", "*", "ClientConfig", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "signalfuseSourceName", ":=", "conf", ".", "SourceName", ".", "Get", "(", ")", "\n", "if", "signalfuseSourceName", "!=", "...
// DefaultDimensions extracts default sfxclient dimensions that identify the host
[ "DefaultDimensions", "extracts", "default", "sfxclient", "dimensions", "that", "identify", "the", "host" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L45-L55
140,727
signalfx/golib
clientcfg/client.go
WatchHTTPSinkChange
func WatchHTTPSinkChange(httpSink *sfxclient.HTTPSink, Conf *ClientConfig, logger log.Logger) *ClientConfigChangerSink { ret := &ClientConfigChangerSink{ Destination: httpSink, urlParse: url.Parse, logger: logger, } ret.authTokenWatch(Conf.AuthToken, "") ret.endpointWatch(Conf.Endpoint, "") ret.disab...
go
func WatchHTTPSinkChange(httpSink *sfxclient.HTTPSink, Conf *ClientConfig, logger log.Logger) *ClientConfigChangerSink { ret := &ClientConfigChangerSink{ Destination: httpSink, urlParse: url.Parse, logger: logger, } ret.authTokenWatch(Conf.AuthToken, "") ret.endpointWatch(Conf.Endpoint, "") ret.disab...
[ "func", "WatchHTTPSinkChange", "(", "httpSink", "*", "sfxclient", ".", "HTTPSink", ",", "Conf", "*", "ClientConfig", ",", "logger", "log", ".", "Logger", ")", "*", "ClientConfigChangerSink", "{", "ret", ":=", "&", "ClientConfigChangerSink", "{", "Destination", "...
// WatchHTTPSinkChange returns anew ClientConfigChangerSink that takes an http sink, instead of a regular sinc
[ "WatchHTTPSinkChange", "returns", "anew", "ClientConfigChangerSink", "that", "takes", "an", "http", "sink", "instead", "of", "a", "regular", "sinc" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L75-L88
140,728
signalfx/golib
clientcfg/client.go
AddDatapoints
func (s *ClientConfigChangerSink) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint) error { s.mu.RLock() defer s.mu.RUnlock() return s.Destination.AddDatapoints(ctx, points) }
go
func (s *ClientConfigChangerSink) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint) error { s.mu.RLock() defer s.mu.RUnlock() return s.Destination.AddDatapoints(ctx, points) }
[ "func", "(", "s", "*", "ClientConfigChangerSink", ")", "AddDatapoints", "(", "ctx", "context", ".", "Context", ",", "points", "[", "]", "*", "datapoint", ".", "Datapoint", ")", "error", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ...
// AddDatapoints forwards the call to Destination
[ "AddDatapoints", "forwards", "the", "call", "to", "Destination" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L91-L95
140,729
signalfx/golib
clientcfg/client.go
AddSpans
func (s *ClientConfigChangerSink) AddSpans(ctx context.Context, spans []*trace.Span) error { s.mu.RLock() defer s.mu.RUnlock() return s.Destination.AddSpans(ctx, spans) }
go
func (s *ClientConfigChangerSink) AddSpans(ctx context.Context, spans []*trace.Span) error { s.mu.RLock() defer s.mu.RUnlock() return s.Destination.AddSpans(ctx, spans) }
[ "func", "(", "s", "*", "ClientConfigChangerSink", ")", "AddSpans", "(", "ctx", "context", ".", "Context", ",", "spans", "[", "]", "*", "trace", ".", "Span", ")", "error", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ...
// AddSpans forwards the call to Destination
[ "AddSpans", "forwards", "the", "call", "to", "Destination" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L98-L102
140,730
signalfx/golib
clientcfg/client.go
AddEvents
func (s *ClientConfigChangerSink) AddEvents(ctx context.Context, events []*event.Event) error { s.mu.RLock() defer s.mu.RUnlock() return s.Destination.AddEvents(ctx, events) }
go
func (s *ClientConfigChangerSink) AddEvents(ctx context.Context, events []*event.Event) error { s.mu.RLock() defer s.mu.RUnlock() return s.Destination.AddEvents(ctx, events) }
[ "func", "(", "s", "*", "ClientConfigChangerSink", ")", "AddEvents", "(", "ctx", "context", ".", "Context", ",", "events", "[", "]", "*", "event", ".", "Event", ")", "error", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu"...
// AddEvents forwards the call to Destination
[ "AddEvents", "forwards", "the", "call", "to", "Destination" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L105-L109
140,731
signalfx/golib
clientcfg/client.go
endpointWatch
func (s *ClientConfigChangerSink) endpointWatch(str *distconf.Str, oldValue string) { s.logger.Log("endpoint watch") e := str.Get() if e == "" { return } if !strings.HasPrefix(e, "http") { e = "http://" + e } u, err := s.urlParse(e) if err != nil { s.logger.Log(logkey.Endpoint, e, log.Err, err, "unable to...
go
func (s *ClientConfigChangerSink) endpointWatch(str *distconf.Str, oldValue string) { s.logger.Log("endpoint watch") e := str.Get() if e == "" { return } if !strings.HasPrefix(e, "http") { e = "http://" + e } u, err := s.urlParse(e) if err != nil { s.logger.Log(logkey.Endpoint, e, log.Err, err, "unable to...
[ "func", "(", "s", "*", "ClientConfigChangerSink", ")", "endpointWatch", "(", "str", "*", "distconf", ".", "Str", ",", "oldValue", "string", ")", "{", "s", ".", "logger", ".", "Log", "(", "\"", "\"", ")", "\n", "e", ":=", "str", ".", "Get", "(", ")"...
// endpointWatch returns a distconf watch that sets the correct ingest endpoint for a signalfx // client
[ "endpointWatch", "returns", "a", "distconf", "watch", "that", "sets", "the", "correct", "ingest", "endpoint", "for", "a", "signalfx", "client" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/clientcfg/client.go#L127-L150
140,732
signalfx/golib
reportsha/reportsha.go
Var
func (s *SHA1Reporter) Var() expvar.Var { s.loadFileInfo() return expvar.Func(func() interface{} { return s.Fi }) }
go
func (s *SHA1Reporter) Var() expvar.Var { s.loadFileInfo() return expvar.Func(func() interface{} { return s.Fi }) }
[ "func", "(", "s", "*", "SHA1Reporter", ")", "Var", "(", ")", "expvar", ".", "Var", "{", "s", ".", "loadFileInfo", "(", ")", "\n", "return", "expvar", ".", "Func", "(", "func", "(", ")", "interface", "{", "}", "{", "return", "s", ".", "Fi", "\n", ...
// Var returns an expvar that is the build file info
[ "Var", "returns", "an", "expvar", "that", "is", "the", "build", "file", "info" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/reportsha/reportsha.go#L58-L63
140,733
signalfx/golib
reportsha/reportsha.go
Datapoints
func (s *SHA1Reporter) Datapoints() []*datapoint.Datapoint { s.loadFileInfo() return []*datapoint.Datapoint{ sfxclient.Gauge("fileinfo_commit", map[string]string{"commit": s.Fi.Commit}, int64(1)), } }
go
func (s *SHA1Reporter) Datapoints() []*datapoint.Datapoint { s.loadFileInfo() return []*datapoint.Datapoint{ sfxclient.Gauge("fileinfo_commit", map[string]string{"commit": s.Fi.Commit}, int64(1)), } }
[ "func", "(", "s", "*", "SHA1Reporter", ")", "Datapoints", "(", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "s", ".", "loadFileInfo", "(", ")", "\n", "return", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "sfxclient", ".", "Gauge", "...
// Datapoints returns a single datapoint that includes the commit sha loaded from a config file
[ "Datapoints", "returns", "a", "single", "datapoint", "that", "includes", "the", "commit", "sha", "loaded", "from", "a", "config", "file" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/reportsha/reportsha.go#L66-L71
140,734
signalfx/golib
errors/log.go
LogIfErr
func LogIfErr(err error, l Loggable, msg string, args ...interface{}) { if err != nil { l.Printf("%s: %s", err.Error(), fmt.Sprintf(msg, args...)) } }
go
func LogIfErr(err error, l Loggable, msg string, args ...interface{}) { if err != nil { l.Printf("%s: %s", err.Error(), fmt.Sprintf(msg, args...)) } }
[ "func", "LogIfErr", "(", "err", "error", ",", "l", "Loggable", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "err", "!=", "nil", "{", "l", ".", "Printf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ",...
// LogIfErr will log to l a Printf message if err is not nil
[ "LogIfErr", "will", "log", "to", "l", "a", "Printf", "message", "if", "err", "is", "not", "nil" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/errors/log.go#L11-L15
140,735
signalfx/golib
errors/log.go
PanicIfErr
func PanicIfErr(err error, msg string, args ...interface{}) { if err != nil { panic(fmt.Sprintf("%s: %s", err.Error(), fmt.Sprintf(msg, args...))) } }
go
func PanicIfErr(err error, msg string, args ...interface{}) { if err != nil { panic(fmt.Sprintf("%s: %s", err.Error(), fmt.Sprintf(msg, args...))) } }
[ "func", "PanicIfErr", "(", "err", "error", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ",", ...
// PanicIfErr is useful if writing shell scripts. It will panic with a msg if err != nil
[ "PanicIfErr", "is", "useful", "if", "writing", "shell", "scripts", ".", "It", "will", "panic", "with", "a", "msg", "if", "err", "!", "=", "nil" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/errors/log.go#L34-L38
140,736
signalfx/golib
errors/log.go
PanicIfErrWrite
func PanicIfErrWrite(numWritten int, err error) { if err != nil { panic(fmt.Sprintf("Write err: %s", err.Error())) } }
go
func PanicIfErrWrite(numWritten int, err error) { if err != nil { panic(fmt.Sprintf("Write err: %s", err.Error())) } }
[ "func", "PanicIfErrWrite", "(", "numWritten", "int", ",", "err", "error", ")", "{", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", ")", "\n", "}", "\n", "}" ]
// PanicIfErrWrite is similar to PanicIfErr, but works well with io results that return integer+err
[ "PanicIfErrWrite", "is", "similar", "to", "PanicIfErr", "but", "works", "well", "with", "io", "results", "that", "return", "integer", "+", "err" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/errors/log.go#L41-L45
140,737
signalfx/golib
expvar2/handler.go
New
func New() *Handler { e := Handler{ Exported: make(map[string]expvar.Var), Logger: log.Discard, } return &e }
go
func New() *Handler { e := Handler{ Exported: make(map[string]expvar.Var), Logger: log.Discard, } return &e }
[ "func", "New", "(", ")", "*", "Handler", "{", "e", ":=", "Handler", "{", "Exported", ":", "make", "(", "map", "[", "string", "]", "expvar", ".", "Var", ")", ",", "Logger", ":", "log", ".", "Discard", ",", "}", "\n", "return", "&", "e", "\n", "}...
// New creates and returns a new handler
[ "New", "creates", "and", "returns", "a", "new", "handler" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/expvar2/handler.go#L24-L30
140,738
signalfx/golib
distconf/ini.go
Ini
func Ini(filename string) (Reader, error) { file, err := ini.LoadFile(filename) if err != nil { return nil, errors.Annotatef(err, "Unable to open file %s", filename) } return &propertyFileDisco{ filename: filename, file: file, }, nil }
go
func Ini(filename string) (Reader, error) { file, err := ini.LoadFile(filename) if err != nil { return nil, errors.Annotatef(err, "Unable to open file %s", filename) } return &propertyFileDisco{ filename: filename, file: file, }, nil }
[ "func", "Ini", "(", "filename", "string", ")", "(", "Reader", ",", "error", ")", "{", "file", ",", "err", ":=", "ini", ".", "LoadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotatef", "("...
// Ini creates a backing config reader that reads properties from an Ini file
[ "Ini", "creates", "a", "backing", "config", "reader", "that", "reads", "properties", "from", "an", "Ini", "file" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/distconf/ini.go#L23-L33
140,739
signalfx/golib
distconf/duration.go
Get
func (s *Duration) Get() time.Duration { return time.Duration(atomic.LoadInt64(&s.currentVal)) }
go
func (s *Duration) Get() time.Duration { return time.Duration(atomic.LoadInt64(&s.currentVal)) }
[ "func", "(", "s", "*", "Duration", ")", "Get", "(", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "atomic", ".", "LoadInt64", "(", "&", "s", ".", "currentVal", ")", ")", "\n", "}" ]
// Get the string in this config variable
[ "Get", "the", "string", "in", "this", "config", "variable" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/distconf/duration.go#L30-L32
140,740
signalfx/golib
distconf/duration.go
Update
func (s *durationConf) Update(newValue []byte) error { s.mutex.Lock() defer s.mutex.Unlock() oldValue := s.Get() if newValue == nil { atomic.StoreInt64(&s.currentVal, int64(s.defaultVal)) } else { newValDuration, err := time.ParseDuration(string(newValue)) if err != nil { s.logger.Log(log.Err, err, logkey...
go
func (s *durationConf) Update(newValue []byte) error { s.mutex.Lock() defer s.mutex.Unlock() oldValue := s.Get() if newValue == nil { atomic.StoreInt64(&s.currentVal, int64(s.defaultVal)) } else { newValDuration, err := time.ParseDuration(string(newValue)) if err != nil { s.logger.Log(log.Err, err, logkey...
[ "func", "(", "s", "*", "durationConf", ")", "Update", "(", "newValue", "[", "]", "byte", ")", "error", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "oldValue", ":=", "s", ".", "...
// Update the contents of Duration to the new value
[ "Update", "the", "contents", "of", "Duration", "to", "the", "new", "value" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/distconf/duration.go#L35-L57
140,741
signalfx/golib
timekeeper/timekeeper.go
NewTimer
func (RealTime) NewTimer(d time.Duration) Timer { return &builtinTimer{ timer: time.NewTimer(d), } }
go
func (RealTime) NewTimer(d time.Duration) Timer { return &builtinTimer{ timer: time.NewTimer(d), } }
[ "func", "(", "RealTime", ")", "NewTimer", "(", "d", "time", ".", "Duration", ")", "Timer", "{", "return", "&", "builtinTimer", "{", "timer", ":", "time", ".", "NewTimer", "(", "d", ")", ",", "}", "\n", "}" ]
// NewTimer calls time.NewTimer and gives it a stubable interface
[ "NewTimer", "calls", "time", ".", "NewTimer", "and", "gives", "it", "a", "stubable", "interface" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/timekeeper/timekeeper.go#L58-L62
140,742
signalfx/golib
disco/thrift.go
NewThriftTransport
func NewThriftTransport(service *Service, timeout time.Duration) *ThriftTransport { return NewThriftTransportWithMaxBufferSize(service, timeout, thrift.DEFAULT_MAX_LENGTH) }
go
func NewThriftTransport(service *Service, timeout time.Duration) *ThriftTransport { return NewThriftTransportWithMaxBufferSize(service, timeout, thrift.DEFAULT_MAX_LENGTH) }
[ "func", "NewThriftTransport", "(", "service", "*", "Service", ",", "timeout", "time", ".", "Duration", ")", "*", "ThriftTransport", "{", "return", "NewThriftTransportWithMaxBufferSize", "(", "service", ",", "timeout", ",", "thrift", ".", "DEFAULT_MAX_LENGTH", ")", ...
// NewThriftTransport creates a new ThriftTransport. The default transport factory is TFramed
[ "NewThriftTransport", "creates", "a", "new", "ThriftTransport", ".", "The", "default", "transport", "factory", "is", "TFramed" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L28-L30
140,743
signalfx/golib
disco/thrift.go
NewThriftTransportWithMaxBufferSize
func NewThriftTransportWithMaxBufferSize(service *Service, timeout time.Duration, maxLength uint32) *ThriftTransport { return &ThriftTransport{ WrappedFactory: thrift.NewTFramedTransportFactoryMaxLength(thrift.NewTTransportFactory(), maxLength), service: service, randSource: rand.New(rand.NewSource(ti...
go
func NewThriftTransportWithMaxBufferSize(service *Service, timeout time.Duration, maxLength uint32) *ThriftTransport { return &ThriftTransport{ WrappedFactory: thrift.NewTFramedTransportFactoryMaxLength(thrift.NewTTransportFactory(), maxLength), service: service, randSource: rand.New(rand.NewSource(ti...
[ "func", "NewThriftTransportWithMaxBufferSize", "(", "service", "*", "Service", ",", "timeout", "time", ".", "Duration", ",", "maxLength", "uint32", ")", "*", "ThriftTransport", "{", "return", "&", "ThriftTransport", "{", "WrappedFactory", ":", "thrift", ".", "NewT...
// NewThriftTransportWithMaxBufferSize creates a new ThriftTransport for TFramedTransport but sets // the maximum size for request frames.
[ "NewThriftTransportWithMaxBufferSize", "creates", "a", "new", "ThriftTransport", "for", "TFramedTransport", "but", "sets", "the", "maximum", "size", "for", "request", "frames", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L34-L44
140,744
signalfx/golib
disco/thrift.go
Flush
func (d *ThriftTransport) Flush() (err error) { if d.currentTransport == nil { return nil } err = d.currentTransport.Flush() if err != nil { log.IfErr(d.logger, d.currentTransport.Close()) d.currentTransport = nil } return errors.Annotate(err, "cannot flush current transport") }
go
func (d *ThriftTransport) Flush() (err error) { if d.currentTransport == nil { return nil } err = d.currentTransport.Flush() if err != nil { log.IfErr(d.logger, d.currentTransport.Close()) d.currentTransport = nil } return errors.Annotate(err, "cannot flush current transport") }
[ "func", "(", "d", "*", "ThriftTransport", ")", "Flush", "(", ")", "(", "err", "error", ")", "{", "if", "d", ".", "currentTransport", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "err", "=", "d", ".", "currentTransport", ".", "Flush", "(", ")...
// Flush the underline transport
[ "Flush", "the", "underline", "transport" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L47-L57
140,745
signalfx/golib
disco/thrift.go
IsOpen
func (d *ThriftTransport) IsOpen() bool { return d.currentTransport != nil && d.currentTransport.IsOpen() }
go
func (d *ThriftTransport) IsOpen() bool { return d.currentTransport != nil && d.currentTransport.IsOpen() }
[ "func", "(", "d", "*", "ThriftTransport", ")", "IsOpen", "(", ")", "bool", "{", "return", "d", ".", "currentTransport", "!=", "nil", "&&", "d", ".", "currentTransport", ".", "IsOpen", "(", ")", "\n", "}" ]
// IsOpen will return true if there is a connected underline transport and it is open
[ "IsOpen", "will", "return", "true", "if", "there", "is", "a", "connected", "underline", "transport", "and", "it", "is", "open" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L60-L62
140,746
signalfx/golib
disco/thrift.go
Close
func (d *ThriftTransport) Close() error { if d.currentTransport == nil { return nil } ret := d.currentTransport.Close() d.currentTransport = nil return errors.Annotate(ret, "cannot close current transport") }
go
func (d *ThriftTransport) Close() error { if d.currentTransport == nil { return nil } ret := d.currentTransport.Close() d.currentTransport = nil return errors.Annotate(ret, "cannot close current transport") }
[ "func", "(", "d", "*", "ThriftTransport", ")", "Close", "(", ")", "error", "{", "if", "d", ".", "currentTransport", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "ret", ":=", "d", ".", "currentTransport", ".", "Close", "(", ")", "\n", "d", "....
// Close and nil the underline transport
[ "Close", "and", "nil", "the", "underline", "transport" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L65-L72
140,747
signalfx/golib
disco/thrift.go
Read
func (d *ThriftTransport) Read(b []byte) (n int, err error) { if d.currentTransport == nil { return 0, thrift.NewTTransportException(thrift.NOT_OPEN, "") } var e1 error var e2 error n, e1 = d.currentTransport.Read(b) if e1 != nil { e2 = d.Close() } err = errors.NewMultiErr([]error{e1, e2}) return }
go
func (d *ThriftTransport) Read(b []byte) (n int, err error) { if d.currentTransport == nil { return 0, thrift.NewTTransportException(thrift.NOT_OPEN, "") } var e1 error var e2 error n, e1 = d.currentTransport.Read(b) if e1 != nil { e2 = d.Close() } err = errors.NewMultiErr([]error{e1, e2}) return }
[ "func", "(", "d", "*", "ThriftTransport", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "d", ".", "currentTransport", "==", "nil", "{", "return", "0", ",", "thrift", ".", "NewTTransportException",...
// Read bytes from underline transport if it is not nil. Exact definition defined in TTransport
[ "Read", "bytes", "from", "underline", "transport", "if", "it", "is", "not", "nil", ".", "Exact", "definition", "defined", "in", "TTransport" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L75-L87
140,748
signalfx/golib
disco/thrift.go
NextConnectionN
func (d *ThriftTransport) NextConnectionN(startIndex int) error { if d.currentTransport != nil && d.currentTransport.IsOpen() { // TODO: Log errors on Close log.IfErr(d.logger, d.currentTransport.Close()) } instances := d.service.ServiceInstances() if len(instances) == 0 { return ErrNoInstance } if startInd...
go
func (d *ThriftTransport) NextConnectionN(startIndex int) error { if d.currentTransport != nil && d.currentTransport.IsOpen() { // TODO: Log errors on Close log.IfErr(d.logger, d.currentTransport.Close()) } instances := d.service.ServiceInstances() if len(instances) == 0 { return ErrNoInstance } if startInd...
[ "func", "(", "d", "*", "ThriftTransport", ")", "NextConnectionN", "(", "startIndex", "int", ")", "error", "{", "if", "d", ".", "currentTransport", "!=", "nil", "&&", "d", ".", "currentTransport", ".", "IsOpen", "(", ")", "{", "// TODO: Log errors on Close", ...
// NextConnectionN will connect this transport disco service, or return an error // if no disco service can be dialed
[ "NextConnectionN", "will", "connect", "this", "transport", "disco", "service", "or", "return", "an", "error", "if", "no", "disco", "service", "can", "be", "dialed" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L118-L142
140,749
signalfx/golib
disco/thrift.go
Open
func (d *ThriftTransport) Open() error { if d.currentTransport == nil || !d.currentTransport.IsOpen() { return errors.Annotate(d.NextConnection(), "cannot open next connection") } return nil }
go
func (d *ThriftTransport) Open() error { if d.currentTransport == nil || !d.currentTransport.IsOpen() { return errors.Annotate(d.NextConnection(), "cannot open next connection") } return nil }
[ "func", "(", "d", "*", "ThriftTransport", ")", "Open", "(", ")", "error", "{", "if", "d", ".", "currentTransport", "==", "nil", "||", "!", "d", ".", "currentTransport", ".", "IsOpen", "(", ")", "{", "return", "errors", ".", "Annotate", "(", "d", ".",...
// Open a connection if one does not exist, otherwise do nothing.
[ "Open", "a", "connection", "if", "one", "does", "not", "exist", "otherwise", "do", "nothing", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L145-L150
140,750
signalfx/golib
disco/thrift.go
RemainingBytes
func (d *ThriftTransport) RemainingBytes() uint64 { if d.currentTransport == nil { // Looking at the thrift code, I think this is the right thing to do. This public interface // and function is not documented by thrift. const maxSize = ^uint64(0) return maxSize // the thruth is, we just don't know unless fram...
go
func (d *ThriftTransport) RemainingBytes() uint64 { if d.currentTransport == nil { // Looking at the thrift code, I think this is the right thing to do. This public interface // and function is not documented by thrift. const maxSize = ^uint64(0) return maxSize // the thruth is, we just don't know unless fram...
[ "func", "(", "d", "*", "ThriftTransport", ")", "RemainingBytes", "(", ")", "uint64", "{", "if", "d", ".", "currentTransport", "==", "nil", "{", "// Looking at the thrift code, I think this is the right thing to do. This public interface", "// and function is not documented by ...
// RemainingBytes of underline transport, or maxSize if not set
[ "RemainingBytes", "of", "underline", "transport", "or", "maxSize", "if", "not", "set" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/disco/thrift.go#L153-L161
140,751
signalfx/golib
web/ctxflag.go
SetFlagStr
func (m *HeaderCtxFlag) SetFlagStr(headerVal string) { m.mu.Lock() m.expectedVal = headerVal m.mu.Unlock() }
go
func (m *HeaderCtxFlag) SetFlagStr(headerVal string) { m.mu.Lock() m.expectedVal = headerVal m.mu.Unlock() }
[ "func", "(", "m", "*", "HeaderCtxFlag", ")", "SetFlagStr", "(", "headerVal", "string", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "m", ".", "expectedVal", "=", "headerVal", "\n", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
// SetFlagStr enabled flag setting for HeaderName if it's equal to headerVal
[ "SetFlagStr", "enabled", "flag", "setting", "for", "HeaderName", "if", "it", "s", "equal", "to", "headerVal" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L30-L34
140,752
signalfx/golib
web/ctxflag.go
WithFlag
func (m *HeaderCtxFlag) WithFlag(ctx context.Context) context.Context { return context.WithValue(ctx, m, struct{}{}) }
go
func (m *HeaderCtxFlag) WithFlag(ctx context.Context) context.Context { return context.WithValue(ctx, m, struct{}{}) }
[ "func", "(", "m", "*", "HeaderCtxFlag", ")", "WithFlag", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "m", ",", "struct", "{", "}", "{", "}", ")", "\n", "}" ]
// WithFlag returns a new Context that has the flag for this context set
[ "WithFlag", "returns", "a", "new", "Context", "that", "has", "the", "flag", "for", "this", "context", "set" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L37-L39
140,753
signalfx/golib
web/ctxflag.go
HasFlag
func (m *HeaderCtxFlag) HasFlag(ctx context.Context) bool { return ctx.Value(m) != nil }
go
func (m *HeaderCtxFlag) HasFlag(ctx context.Context) bool { return ctx.Value(m) != nil }
[ "func", "(", "m", "*", "HeaderCtxFlag", ")", "HasFlag", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "return", "ctx", ".", "Value", "(", "m", ")", "!=", "nil", "\n", "}" ]
// HasFlag returns true if WithFlag has been set for this context
[ "HasFlag", "returns", "true", "if", "WithFlag", "has", "been", "set", "for", "this", "context" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L42-L44
140,754
signalfx/golib
web/ctxflag.go
FlagStr
func (m *HeaderCtxFlag) FlagStr() string { m.mu.RLock() ret := m.expectedVal m.mu.RUnlock() return ret }
go
func (m *HeaderCtxFlag) FlagStr() string { m.mu.RLock() ret := m.expectedVal m.mu.RUnlock() return ret }
[ "func", "(", "m", "*", "HeaderCtxFlag", ")", "FlagStr", "(", ")", "string", "{", "m", ".", "mu", ".", "RLock", "(", ")", "\n", "ret", ":=", "m", ".", "expectedVal", "\n", "m", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "ret", "\n", "}...
// FlagStr returns the currently set flag header
[ "FlagStr", "returns", "the", "currently", "set", "flag", "header" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L47-L52
140,755
signalfx/golib
web/ctxflag.go
ServeHTTPC
func (m *HeaderCtxFlag) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, r *http.Request, next ContextHandler) { debugStr := m.FlagStr() if debugStr != "" && m.HeaderName != "" { if r.Header.Get(m.HeaderName) == debugStr { ctx = m.WithFlag(ctx) } else if r.URL.Query().Get(m.HeaderName) == debugStr { ...
go
func (m *HeaderCtxFlag) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, r *http.Request, next ContextHandler) { debugStr := m.FlagStr() if debugStr != "" && m.HeaderName != "" { if r.Header.Get(m.HeaderName) == debugStr { ctx = m.WithFlag(ctx) } else if r.URL.Query().Get(m.HeaderName) == debugStr { ...
[ "func", "(", "m", "*", "HeaderCtxFlag", ")", "ServeHTTPC", "(", "ctx", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "next", "ContextHandler", ")", "{", "debugStr", ":=", "m", ".", "Fla...
// ServeHTTPC calls next with a context flagged if the headers match. Note it checks both headers and query parameters.
[ "ServeHTTPC", "calls", "next", "with", "a", "context", "flagged", "if", "the", "headers", "match", ".", "Note", "it", "checks", "both", "headers", "and", "query", "parameters", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L55-L65
140,756
signalfx/golib
web/ctxflag.go
ServeHTTPC
func (m *HeadersInRequest) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, r *http.Request, next ContextHandler) { for k, v := range m.Headers { rw.Header().Add(k, v) } next.ServeHTTPC(ctx, rw, r) }
go
func (m *HeadersInRequest) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, r *http.Request, next ContextHandler) { for k, v := range m.Headers { rw.Header().Add(k, v) } next.ServeHTTPC(ctx, rw, r) }
[ "func", "(", "m", "*", "HeadersInRequest", ")", "ServeHTTPC", "(", "ctx", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "next", "ContextHandler", ")", "{", "for", "k", ",", "v", ":=", ...
// ServeHTTPC will add headers to rw if ctx has the flag set
[ "ServeHTTPC", "will", "add", "headers", "to", "rw", "if", "ctx", "has", "the", "flag", "set" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L73-L78
140,757
signalfx/golib
web/ctxflag.go
CreateMiddleware
func (m *HeadersInRequest) CreateMiddleware(next ContextHandler) ContextHandler { return HandlerFunc(func(ctx context.Context, rw http.ResponseWriter, r *http.Request) { m.ServeHTTPC(ctx, rw, r, next) }) }
go
func (m *HeadersInRequest) CreateMiddleware(next ContextHandler) ContextHandler { return HandlerFunc(func(ctx context.Context, rw http.ResponseWriter, r *http.Request) { m.ServeHTTPC(ctx, rw, r, next) }) }
[ "func", "(", "m", "*", "HeadersInRequest", ")", "CreateMiddleware", "(", "next", "ContextHandler", ")", "ContextHandler", "{", "return", "HandlerFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "r", "*...
// CreateMiddleware creates a handler that calls next as the next in the chain
[ "CreateMiddleware", "creates", "a", "handler", "that", "calls", "next", "as", "the", "next", "in", "the", "chain" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L81-L85
140,758
signalfx/golib
web/ctxflag.go
ServeHTTPC
func (m *CtxWithFlag) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, r *http.Request, next ContextHandler) { headerid := rand.Int63() rw.Header().Add(m.HeaderName, strconv.FormatInt(headerid, 10)) ctx = m.CtxFlagger.Append(ctx, "header_id", headerid, "http_remote_addr", r.RemoteAddr, "http_method", r.Method...
go
func (m *CtxWithFlag) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, r *http.Request, next ContextHandler) { headerid := rand.Int63() rw.Header().Add(m.HeaderName, strconv.FormatInt(headerid, 10)) ctx = m.CtxFlagger.Append(ctx, "header_id", headerid, "http_remote_addr", r.RemoteAddr, "http_method", r.Method...
[ "func", "(", "m", "*", "CtxWithFlag", ")", "ServeHTTPC", "(", "ctx", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "next", "ContextHandler", ")", "{", "headerid", ":=", "rand", ".", "In...
// ServeHTTPC adds useful request dims to the next context
[ "ServeHTTPC", "adds", "useful", "request", "dims", "to", "the", "next", "context" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/ctxflag.go#L95-L100
140,759
signalfx/golib
datapoint/dpsink/filter.go
FilterDatapoints
func (e *EmptyMetricFilter) FilterDatapoints(points []*datapoint.Datapoint) []*datapoint.Datapoint { validDatapoints := make([]*datapoint.Datapoint, 0, len(points)) for _, dat := range points { if dat.Metric != "" { validDatapoints = append(validDatapoints, dat) } } invalidDatumCount := int64(len(points) - l...
go
func (e *EmptyMetricFilter) FilterDatapoints(points []*datapoint.Datapoint) []*datapoint.Datapoint { validDatapoints := make([]*datapoint.Datapoint, 0, len(points)) for _, dat := range points { if dat.Metric != "" { validDatapoints = append(validDatapoints, dat) } } invalidDatumCount := int64(len(points) - l...
[ "func", "(", "e", "*", "EmptyMetricFilter", ")", "FilterDatapoints", "(", "points", "[", "]", "*", "datapoint", ".", "Datapoint", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "validDatapoints", ":=", "make", "(", "[", "]", "*", "datapoint", "....
// FilterDatapoints returns points that have a non empty metric name
[ "FilterDatapoints", "returns", "points", "that", "have", "a", "non", "empty", "metric", "name" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/filter.go#L16-L28
140,760
signalfx/golib
datapoint/dpsink/filter.go
AddDatapoints
func (e *EmptyMetricFilter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { validDatapoints := e.FilterDatapoints(points) if len(validDatapoints) == 0 { return nil } return next.AddDatapoints(ctx, validDatapoints) }
go
func (e *EmptyMetricFilter) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error { validDatapoints := e.FilterDatapoints(points) if len(validDatapoints) == 0 { return nil } return next.AddDatapoints(ctx, validDatapoints) }
[ "func", "(", "e", "*", "EmptyMetricFilter", ")", "AddDatapoints", "(", "ctx", "context", ".", "Context", ",", "points", "[", "]", "*", "datapoint", ".", "Datapoint", ",", "next", "Sink", ")", "error", "{", "validDatapoints", ":=", "e", ".", "FilterDatapoin...
// AddDatapoints will send points to the next sink that have a non empty metric name
[ "AddDatapoints", "will", "send", "points", "to", "the", "next", "sink", "that", "have", "a", "non", "empty", "metric", "name" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/datapoint/dpsink/filter.go#L31-L37
140,761
signalfx/golib
maestro/load.go
ShipsForService
func (c *Config) ShipsForService(name string) []string { zkInstances := c.Services[name].Instances inst := make([]string, 0, len(zkInstances)) for _, i := range zkInstances { zkShip := c.Ships[i.Ship] c := fmt.Sprintf("%s:%d", zkShip.IP, int64(i.Ports["client"].(float64))) inst = append(inst, c) } return ins...
go
func (c *Config) ShipsForService(name string) []string { zkInstances := c.Services[name].Instances inst := make([]string, 0, len(zkInstances)) for _, i := range zkInstances { zkShip := c.Ships[i.Ship] c := fmt.Sprintf("%s:%d", zkShip.IP, int64(i.Ports["client"].(float64))) inst = append(inst, c) } return ins...
[ "func", "(", "c", "*", "Config", ")", "ShipsForService", "(", "name", "string", ")", "[", "]", "string", "{", "zkInstances", ":=", "c", ".", "Services", "[", "name", "]", ".", "Instances", "\n", "inst", ":=", "make", "(", "[", "]", "string", ",", "...
// ShipsForService is a helper that gets the connections for a service inside a config
[ "ShipsForService", "is", "a", "helper", "that", "gets", "the", "connections", "for", "a", "service", "inside", "a", "config" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/maestro/load.go#L42-L51
140,762
signalfx/golib
maestro/load.go
Load
func (l *Loader) Load(filename string) (*Config, error) { f := l.ExecFunc if f == nil { f = safeexec.Execute } pythonLocation := l.PythonLocation if pythonLocation == "" { pythonLocation = "python" } stdout, stderr, err := f(pythonLocation, filename, "-c", "import maestro.__main__ as maestro, sys, json;print...
go
func (l *Loader) Load(filename string) (*Config, error) { f := l.ExecFunc if f == nil { f = safeexec.Execute } pythonLocation := l.PythonLocation if pythonLocation == "" { pythonLocation = "python" } stdout, stderr, err := f(pythonLocation, filename, "-c", "import maestro.__main__ as maestro, sys, json;print...
[ "func", "(", "l", "*", "Loader", ")", "Load", "(", "filename", "string", ")", "(", "*", "Config", ",", "error", ")", "{", "f", ":=", "l", ".", "ExecFunc", "\n", "if", "f", "==", "nil", "{", "f", "=", "safeexec", ".", "Execute", "\n", "}", "\n",...
// Load a maestro config, shelling out to python
[ "Load", "a", "maestro", "config", "shelling", "out", "to", "python" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/maestro/load.go#L80-L99
140,763
signalfx/golib
log/multi.go
Log
func (c MultiLogger) Log(keyvals ...interface{}) { for _, l := range c { if !IsDisabled(l) { l.Log(keyvals...) } } }
go
func (c MultiLogger) Log(keyvals ...interface{}) { for _, l := range c { if !IsDisabled(l) { l.Log(keyvals...) } } }
[ "func", "(", "c", "MultiLogger", ")", "Log", "(", "keyvals", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "l", ":=", "range", "c", "{", "if", "!", "IsDisabled", "(", "l", ")", "{", "l", ".", "Log", "(", "keyvals", "...", ")", "\n", ...
// Log will call log on every logger that isn't disabled
[ "Log", "will", "call", "log", "on", "every", "logger", "that", "isn", "t", "disabled" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/multi.go#L9-L15
140,764
signalfx/golib
log/multi.go
Disabled
func (c MultiLogger) Disabled() bool { for _, l := range c { if !IsDisabled(l) { return false } } return true }
go
func (c MultiLogger) Disabled() bool { for _, l := range c { if !IsDisabled(l) { return false } } return true }
[ "func", "(", "c", "MultiLogger", ")", "Disabled", "(", ")", "bool", "{", "for", "_", ",", "l", ":=", "range", "c", "{", "if", "!", "IsDisabled", "(", "l", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Disabled returns true if all the wrapped loggers are disabled
[ "Disabled", "returns", "true", "if", "all", "the", "wrapped", "loggers", "are", "disabled" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/multi.go#L18-L25
140,765
signalfx/golib
maestro/maestro.go
GetContainerHostAddress
func (m *Maestro) GetContainerHostAddress() (string, error) { address := m.osGetenv("CONTAINER_HOST_ADDRESS") if address == "" { return "", ErrContainerHostAddrNotDefined } return address, nil }
go
func (m *Maestro) GetContainerHostAddress() (string, error) { address := m.osGetenv("CONTAINER_HOST_ADDRESS") if address == "" { return "", ErrContainerHostAddrNotDefined } return address, nil }
[ "func", "(", "m", "*", "Maestro", ")", "GetContainerHostAddress", "(", ")", "(", "string", ",", "error", ")", "{", "address", ":=", "m", ".", "osGetenv", "(", "\"", "\"", ")", "\n", "if", "address", "==", "\"", "\"", "{", "return", "\"", "\"", ",",...
// GetContainerHostAddress returns the publicly-addressable IP address of the host of the container
[ "GetContainerHostAddress", "returns", "the", "publicly", "-", "addressable", "IP", "address", "of", "the", "host", "of", "the", "container" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/maestro/maestro.go#L39-L45
140,766
signalfx/golib
maestro/maestro.go
GetServiceName
func (m *Maestro) GetServiceName() (string, error) { address := m.osGetenv("SERVICE_NAME") if address == "" { return "", ErrNoServiceName } return address, nil }
go
func (m *Maestro) GetServiceName() (string, error) { address := m.osGetenv("SERVICE_NAME") if address == "" { return "", ErrNoServiceName } return address, nil }
[ "func", "(", "m", "*", "Maestro", ")", "GetServiceName", "(", ")", "(", "string", ",", "error", ")", "{", "address", ":=", "m", ".", "osGetenv", "(", "\"", "\"", ")", "\n", "if", "address", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "ErrNo...
// GetServiceName returns the service name of the container calling it
[ "GetServiceName", "returns", "the", "service", "name", "of", "the", "container", "calling", "it" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/maestro/maestro.go#L51-L57
140,767
signalfx/golib
maestro/maestro.go
GetContainerName
func (m *Maestro) GetContainerName() (string, error) { address := m.osGetenv("CONTAINER_NAME") if address == "" { return "", ErrNoContainerName } return address, nil }
go
func (m *Maestro) GetContainerName() (string, error) { address := m.osGetenv("CONTAINER_NAME") if address == "" { return "", ErrNoContainerName } return address, nil }
[ "func", "(", "m", "*", "Maestro", ")", "GetContainerName", "(", ")", "(", "string", ",", "error", ")", "{", "address", ":=", "m", ".", "osGetenv", "(", "\"", "\"", ")", "\n", "if", "address", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "Err...
// GetContainerName returns the name of the container calling it
[ "GetContainerName", "returns", "the", "name", "of", "the", "container", "calling", "it" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/maestro/maestro.go#L63-L69
140,768
signalfx/golib
web/reqlatencycounter.go
NewReqLatencyCounter
func NewReqLatencyCounter(fastRequestDurationLimit FastRequestLimitDuration) ReqLatencyCounter { return ReqLatencyCounter{ fastRequestLimitDuration: fastRequestDurationLimit, timeKeeper: timekeeper.RealTime{}, } }
go
func NewReqLatencyCounter(fastRequestDurationLimit FastRequestLimitDuration) ReqLatencyCounter { return ReqLatencyCounter{ fastRequestLimitDuration: fastRequestDurationLimit, timeKeeper: timekeeper.RealTime{}, } }
[ "func", "NewReqLatencyCounter", "(", "fastRequestDurationLimit", "FastRequestLimitDuration", ")", "ReqLatencyCounter", "{", "return", "ReqLatencyCounter", "{", "fastRequestLimitDuration", ":", "fastRequestDurationLimit", ",", "timeKeeper", ":", "timekeeper", ".", "RealTime", ...
// NewReqLatencyCounter creates a new ReqLatencyCounter
[ "NewReqLatencyCounter", "creates", "a", "new", "ReqLatencyCounter" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/reqlatencycounter.go#L27-L32
140,769
signalfx/golib
web/reqlatencycounter.go
ModStats
func (a *ReqLatencyCounter) ModStats(ctx context.Context) { a.ModStatsTime(RequestTime(ctx)) }
go
func (a *ReqLatencyCounter) ModStats(ctx context.Context) { a.ModStatsTime(RequestTime(ctx)) }
[ "func", "(", "a", "*", "ReqLatencyCounter", ")", "ModStats", "(", "ctx", "context", ".", "Context", ")", "{", "a", ".", "ModStatsTime", "(", "RequestTime", "(", "ctx", ")", ")", "\n", "}" ]
// ModStats modifies the metric values for the ReqLatencyCounter.
[ "ModStats", "modifies", "the", "metric", "values", "for", "the", "ReqLatencyCounter", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/reqlatencycounter.go#L35-L37
140,770
signalfx/golib
web/reqlatencycounter.go
ModStatsTime
func (a *ReqLatencyCounter) ModStatsTime(start time.Time) { totalDur := a.timeKeeper.Now().Sub(start) if totalDur > a.fastRequestLimitDuration.Get() { atomic.AddInt64(&a.slowRequests, 1) } else { atomic.AddInt64(&a.fastRequests, 1) } }
go
func (a *ReqLatencyCounter) ModStatsTime(start time.Time) { totalDur := a.timeKeeper.Now().Sub(start) if totalDur > a.fastRequestLimitDuration.Get() { atomic.AddInt64(&a.slowRequests, 1) } else { atomic.AddInt64(&a.fastRequests, 1) } }
[ "func", "(", "a", "*", "ReqLatencyCounter", ")", "ModStatsTime", "(", "start", "time", ".", "Time", ")", "{", "totalDur", ":=", "a", ".", "timeKeeper", ".", "Now", "(", ")", ".", "Sub", "(", "start", ")", "\n", "if", "totalDur", ">", "a", ".", "fas...
// ModStatsTime modifies the metric values for the ReqLatencyCounter.
[ "ModStatsTime", "modifies", "the", "metric", "values", "for", "the", "ReqLatencyCounter", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/reqlatencycounter.go#L40-L47
140,771
signalfx/golib
web/reqlatencycounter.go
appendDimensions
func appendDimensions(dimensions map[string]string, key string, value string) map[string]string { r := make(map[string]string, len(dimensions)+1) for k, v := range dimensions { r[k] = v } r[key] = value return r }
go
func appendDimensions(dimensions map[string]string, key string, value string) map[string]string { r := make(map[string]string, len(dimensions)+1) for k, v := range dimensions { r[k] = v } r[key] = value return r }
[ "func", "appendDimensions", "(", "dimensions", "map", "[", "string", "]", "string", ",", "key", "string", ",", "value", "string", ")", "map", "[", "string", "]", "string", "{", "r", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", ...
// appendDimension will blah blah blah
[ "appendDimension", "will", "blah", "blah", "blah" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/reqlatencycounter.go#L50-L57
140,772
signalfx/golib
web/reqlatencycounter.go
Stats
func (a *ReqLatencyCounter) Stats(dimensions map[string]string) []*datapoint.Datapoint { now := a.timeKeeper.Now() getDp := func(key string, value int64) *datapoint.Datapoint { return datapoint.New( "ReqLatencyCounter.requestCounts", appendDimensions(dimensions, "requestClass", key), datapoint.NewIntValue(val...
go
func (a *ReqLatencyCounter) Stats(dimensions map[string]string) []*datapoint.Datapoint { now := a.timeKeeper.Now() getDp := func(key string, value int64) *datapoint.Datapoint { return datapoint.New( "ReqLatencyCounter.requestCounts", appendDimensions(dimensions, "requestClass", key), datapoint.NewIntValue(val...
[ "func", "(", "a", "*", "ReqLatencyCounter", ")", "Stats", "(", "dimensions", "map", "[", "string", "]", "string", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "now", ":=", "a", ".", "timeKeeper", ".", "Now", "(", ")", "\n", "getDp", ":=", ...
// Stats gets the metrics for a ReqLatencyCounter.
[ "Stats", "gets", "the", "metrics", "for", "a", "ReqLatencyCounter", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/web/reqlatencycounter.go#L60-L71
140,773
signalfx/golib
metadata/hostmetadata/host.go
ToStringMap
func (c *CPU) ToStringMap() map[string]string { return map[string]string{ "host_physical_cpus": strconv.Itoa(c.HostPhysicalCPUs), "host_cpu_cores": strconv.FormatInt(c.HostCPUCores, 10), "host_cpu_model": c.HostCPUModel, "host_logical_cpus": strconv.Itoa(c.HostLogicalCPUs), "host_processor": c.H...
go
func (c *CPU) ToStringMap() map[string]string { return map[string]string{ "host_physical_cpus": strconv.Itoa(c.HostPhysicalCPUs), "host_cpu_cores": strconv.FormatInt(c.HostCPUCores, 10), "host_cpu_model": c.HostCPUModel, "host_logical_cpus": strconv.Itoa(c.HostLogicalCPUs), "host_processor": c.H...
[ "func", "(", "c", "*", "CPU", ")", "ToStringMap", "(", ")", "map", "[", "string", "]", "string", "{", "return", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "strconv", ".", "Itoa", "(", "c", ".", "HostPhysicalCPUs", ")", ",", "\"", ...
// ToStringMap returns the CPU as a string map
[ "ToStringMap", "returns", "the", "CPU", "as", "a", "string", "map" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/hostmetadata/host.go#L45-L54
140,774
signalfx/golib
metadata/hostmetadata/host.go
GetCPU
func GetCPU() (info *CPU, err error) { info = &CPU{} // get physical cpu stats var cpus []cpu.InfoStat if cpus, err = cpuInfo(); err != nil { return info, err } info.HostPhysicalCPUs = len(cpus) // get logical cpu stats if info.HostLogicalCPUs, err = cpuCounts(true); err != nil { return info, err } //...
go
func GetCPU() (info *CPU, err error) { info = &CPU{} // get physical cpu stats var cpus []cpu.InfoStat if cpus, err = cpuInfo(); err != nil { return info, err } info.HostPhysicalCPUs = len(cpus) // get logical cpu stats if info.HostLogicalCPUs, err = cpuCounts(true); err != nil { return info, err } //...
[ "func", "GetCPU", "(", ")", "(", "info", "*", "CPU", ",", "err", "error", ")", "{", "info", "=", "&", "CPU", "{", "}", "\n\n", "// get physical cpu stats", "var", "cpus", "[", "]", "cpu", ".", "InfoStat", "\n", "if", "cpus", ",", "err", "=", "cpuIn...
// GetCPU - adds information about the host cpu to the supplied map
[ "GetCPU", "-", "adds", "information", "about", "the", "host", "cpu", "to", "the", "supplied", "map" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/hostmetadata/host.go#L57-L84
140,775
signalfx/golib
metadata/hostmetadata/host.go
GetOS
func GetOS() (info *OS, err error) { info = &OS{} hInfo, err := hostInfo() if err != nil { return info, err } info.HostOSName = hInfo.Platform info.HostKernelName = hInfo.OS // in gopsutil KernelVersion returns what we would expect for Kernel Release info.HostKernelRelease = hInfo.KernelVersion err = fillP...
go
func GetOS() (info *OS, err error) { info = &OS{} hInfo, err := hostInfo() if err != nil { return info, err } info.HostOSName = hInfo.Platform info.HostKernelName = hInfo.OS // in gopsutil KernelVersion returns what we would expect for Kernel Release info.HostKernelRelease = hInfo.KernelVersion err = fillP...
[ "func", "GetOS", "(", ")", "(", "info", "*", "OS", ",", "err", "error", ")", "{", "info", "=", "&", "OS", "{", "}", "\n", "hInfo", ",", "err", ":=", "hostInfo", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "info", ",", "err", "\...
// GetOS returns a struct with information about the host os
[ "GetOS", "returns", "a", "struct", "with", "information", "about", "the", "host", "os" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/hostmetadata/host.go#L116-L130
140,776
signalfx/golib
metadata/hostmetadata/host.go
GetLinuxVersion
func GetLinuxVersion() (string, error) { etc := HostEtc() if value, err := getStringFromFile(`DISTRIB_DESCRIPTION="(.*)"`, filepath.Join(etc, "lsb-release")); err == nil { return value, nil } if value, err := getStringFromFile(`PRETTY_NAME="(.*)"`, filepath.Join(etc, "os-release")); err == nil { return value, n...
go
func GetLinuxVersion() (string, error) { etc := HostEtc() if value, err := getStringFromFile(`DISTRIB_DESCRIPTION="(.*)"`, filepath.Join(etc, "lsb-release")); err == nil { return value, nil } if value, err := getStringFromFile(`PRETTY_NAME="(.*)"`, filepath.Join(etc, "os-release")); err == nil { return value, n...
[ "func", "GetLinuxVersion", "(", ")", "(", "string", ",", "error", ")", "{", "etc", ":=", "HostEtc", "(", ")", "\n", "if", "value", ",", "err", ":=", "getStringFromFile", "(", "`DISTRIB_DESCRIPTION=\"(.*)\"`", ",", "filepath", ".", "Join", "(", "etc", ",", ...
// GetLinuxVersion - adds information about the host linux version to the supplied map
[ "GetLinuxVersion", "-", "adds", "information", "about", "the", "host", "linux", "version", "to", "the", "supplied", "map" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/hostmetadata/host.go#L133-L151
140,777
signalfx/golib
metadata/hostmetadata/host.go
GetMemory
func GetMemory() (*Memory, error) { m := &Memory{} memoryStat, err := memVirtualMemory() if err == nil { m.Total = dataunit.Size(int64(memoryStat.Total)) } return m, err }
go
func GetMemory() (*Memory, error) { m := &Memory{} memoryStat, err := memVirtualMemory() if err == nil { m.Total = dataunit.Size(int64(memoryStat.Total)) } return m, err }
[ "func", "GetMemory", "(", ")", "(", "*", "Memory", ",", "error", ")", "{", "m", ":=", "&", "Memory", "{", "}", "\n", "memoryStat", ",", "err", ":=", "memVirtualMemory", "(", ")", "\n", "if", "err", "==", "nil", "{", "m", ".", "Total", "=", "datau...
// GetMemory returns the amount of memory on the host as datatype.USize
[ "GetMemory", "returns", "the", "amount", "of", "memory", "on", "the", "host", "as", "datatype", ".", "USize" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/hostmetadata/host.go#L167-L174
140,778
signalfx/golib
sfxclient/wrapper.go
Datapoints
func (m MultiCollector) Datapoints() []*datapoint.Datapoint { var ret []*datapoint.Datapoint for _, col := range m { ret = append(ret, col.Datapoints()...) } return ret }
go
func (m MultiCollector) Datapoints() []*datapoint.Datapoint { var ret []*datapoint.Datapoint for _, col := range m { ret = append(ret, col.Datapoints()...) } return ret }
[ "func", "(", "m", "MultiCollector", ")", "Datapoints", "(", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "var", "ret", "[", "]", "*", "datapoint", ".", "Datapoint", "\n", "for", "_", ",", "col", ":=", "range", "m", "{", "ret", "=", "appe...
// Datapoints returns the datapoints from every collector.
[ "Datapoints", "returns", "the", "datapoints", "from", "every", "collector", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/wrapper.go#L20-L26
140,779
signalfx/golib
sfxclient/wrapper.go
Datapoints
func (w *WithDimensions) Datapoints() []*datapoint.Datapoint { return w.appendDimensions(w.Collector.Datapoints()) }
go
func (w *WithDimensions) Datapoints() []*datapoint.Datapoint { return w.appendDimensions(w.Collector.Datapoints()) }
[ "func", "(", "w", "*", "WithDimensions", ")", "Datapoints", "(", ")", "[", "]", "*", "datapoint", ".", "Datapoint", "{", "return", "w", ".", "appendDimensions", "(", "w", ".", "Collector", ".", "Datapoints", "(", ")", ")", "\n", "}" ]
// Datapoints calls datapoints and adds on Dimensions
[ "Datapoints", "calls", "datapoints", "and", "adds", "on", "Dimensions" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/wrapper.go#L40-L42
140,780
signalfx/golib
log/panic.go
Log
func (n *panicLogger) Log(keyvals ...interface{}) { r := keyvals if n.err != nil { r = append(r[0:len(r):len(r)], n.err) } buf := &bytes.Buffer{} f := LogfmtLogger{ Out: buf, MissingValueKey: Msg, } if err := f.Log(r...); err != nil { panic(r) } panic(buf.String()) }
go
func (n *panicLogger) Log(keyvals ...interface{}) { r := keyvals if n.err != nil { r = append(r[0:len(r):len(r)], n.err) } buf := &bytes.Buffer{} f := LogfmtLogger{ Out: buf, MissingValueKey: Msg, } if err := f.Log(r...); err != nil { panic(r) } panic(buf.String()) }
[ "func", "(", "n", "*", "panicLogger", ")", "Log", "(", "keyvals", "...", "interface", "{", "}", ")", "{", "r", ":=", "keyvals", "\n", "if", "n", ".", "err", "!=", "nil", "{", "r", "=", "append", "(", "r", "[", "0", ":", "len", "(", "r", ")", ...
// Log calls panic for keyvals
[ "Log", "calls", "panic", "for", "keyvals" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/panic.go#L13-L27
140,781
signalfx/golib
explorable/explorable.go
ExploreObject
func ExploreObject(t reflect.Value, path []string) *Result { if ret := checkConsts(t); ret != nil { return ret } ret := &Result{} switch t.Kind() { case reflect.Bool: ret.Desc = fmt.Sprintf("%t", t.Bool()) return ret case reflect.String: ret.Desc = t.String() return ret } c := map[reflect.Kind](func(r...
go
func ExploreObject(t reflect.Value, path []string) *Result { if ret := checkConsts(t); ret != nil { return ret } ret := &Result{} switch t.Kind() { case reflect.Bool: ret.Desc = fmt.Sprintf("%t", t.Bool()) return ret case reflect.String: ret.Desc = t.String() return ret } c := map[reflect.Kind](func(r...
[ "func", "ExploreObject", "(", "t", "reflect", ".", "Value", ",", "path", "[", "]", "string", ")", "*", "Result", "{", "if", "ret", ":=", "checkConsts", "(", "t", ")", ";", "ret", "!=", "nil", "{", "return", "ret", "\n", "}", "\n", "ret", ":=", "&...
// ExploreObject is a crude public way to explore an object's values via reflection
[ "ExploreObject", "is", "a", "crude", "public", "way", "to", "explore", "an", "object", "s", "values", "via", "reflection" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/explorable/explorable.go#L245-L274
140,782
signalfx/golib
log/filter.go
Disabled
func (f *MultiFilter) Disabled() bool { if len(f.Filters) == 0 { return true } for _, filter := range f.Filters { if !filter.Disabled() { return false } } return true }
go
func (f *MultiFilter) Disabled() bool { if len(f.Filters) == 0 { return true } for _, filter := range f.Filters { if !filter.Disabled() { return false } } return true }
[ "func", "(", "f", "*", "MultiFilter", ")", "Disabled", "(", ")", "bool", "{", "if", "len", "(", "f", ".", "Filters", ")", "==", "0", "{", "return", "true", "\n", "}", "\n", "for", "_", ",", "filter", ":=", "range", "f", ".", "Filters", "{", "if...
// Disabled returns true if all inner filters are disabled
[ "Disabled", "returns", "true", "if", "all", "inner", "filters", "are", "disabled" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L29-L39
140,783
signalfx/golib
log/filter.go
Log
func (f *MultiFilter) Log(keyvals ...interface{}) { if f.Disabled() { return } for _, filter := range f.Filters { if filter.WouldLog(keyvals...) { f.PassTo.Log(keyvals...) return } } }
go
func (f *MultiFilter) Log(keyvals ...interface{}) { if f.Disabled() { return } for _, filter := range f.Filters { if filter.WouldLog(keyvals...) { f.PassTo.Log(keyvals...) return } } }
[ "func", "(", "f", "*", "MultiFilter", ")", "Log", "(", "keyvals", "...", "interface", "{", "}", ")", "{", "if", "f", ".", "Disabled", "(", ")", "{", "return", "\n", "}", "\n", "for", "_", ",", "filter", ":=", "range", "f", ".", "Filters", "{", ...
// Log will log out to the first filter
[ "Log", "will", "log", "out", "to", "the", "first", "filter" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L42-L52
140,784
signalfx/golib
log/filter.go
Disabled
func (f *RegexFilter) Disabled() bool { f.mu.RLock() if len(f.currentFilters) == 0 { f.mu.RUnlock() return true } f.mu.RUnlock() return false }
go
func (f *RegexFilter) Disabled() bool { f.mu.RLock() if len(f.currentFilters) == 0 { f.mu.RUnlock() return true } f.mu.RUnlock() return false }
[ "func", "(", "f", "*", "RegexFilter", ")", "Disabled", "(", ")", "bool", "{", "f", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "len", "(", "f", ".", "currentFilters", ")", "==", "0", "{", "f", ".", "mu", ".", "RUnlock", "(", ")", "\n", "re...
// Disabled returns true if there are no current filters enabled.
[ "Disabled", "returns", "true", "if", "there", "are", "no", "current", "filters", "enabled", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L65-L73
140,785
signalfx/golib
log/filter.go
WouldLog
func (f *RegexFilter) WouldLog(keyvals ...interface{}) bool { if f.Disabled() { return false } m := mapFromKeyvals(f.MissingValueKey, keyvals...) shouldPass := false f.mu.RLock() if matches(f.currentFilters, m, f.ErrCallback) { shouldPass = true } f.mu.RUnlock() if shouldPass { return true } return fal...
go
func (f *RegexFilter) WouldLog(keyvals ...interface{}) bool { if f.Disabled() { return false } m := mapFromKeyvals(f.MissingValueKey, keyvals...) shouldPass := false f.mu.RLock() if matches(f.currentFilters, m, f.ErrCallback) { shouldPass = true } f.mu.RUnlock() if shouldPass { return true } return fal...
[ "func", "(", "f", "*", "RegexFilter", ")", "WouldLog", "(", "keyvals", "...", "interface", "{", "}", ")", "bool", "{", "if", "f", ".", "Disabled", "(", ")", "{", "return", "false", "\n", "}", "\n", "m", ":=", "mapFromKeyvals", "(", "f", ".", "Missi...
// WouldLog returns true if the regex matches keyvals dimensions
[ "WouldLog", "returns", "true", "if", "the", "regex", "matches", "keyvals", "dimensions" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L76-L91
140,786
signalfx/golib
log/filter.go
Stats
func (f *RegexFilter) Stats() Stats { return Stats{ ChangeIndex: atomic.LoadInt64(&f.filterChangeIndex), FilterLen: len(f.GetFilters()), } }
go
func (f *RegexFilter) Stats() Stats { return Stats{ ChangeIndex: atomic.LoadInt64(&f.filterChangeIndex), FilterLen: len(f.GetFilters()), } }
[ "func", "(", "f", "*", "RegexFilter", ")", "Stats", "(", ")", "Stats", "{", "return", "Stats", "{", "ChangeIndex", ":", "atomic", ".", "LoadInt64", "(", "&", "f", ".", "filterChangeIndex", ")", ",", "FilterLen", ":", "len", "(", "f", ".", "GetFilters",...
// Stats returns a Stats object that describes the filter
[ "Stats", "returns", "a", "Stats", "object", "that", "describes", "the", "filter" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L120-L125
140,787
signalfx/golib
log/filter.go
GetFilters
func (f *RegexFilter) GetFilters() map[string]*regexp.Regexp { f.mu.RLock() ret := f.currentFilters f.mu.RUnlock() return ret }
go
func (f *RegexFilter) GetFilters() map[string]*regexp.Regexp { f.mu.RLock() ret := f.currentFilters f.mu.RUnlock() return ret }
[ "func", "(", "f", "*", "RegexFilter", ")", "GetFilters", "(", ")", "map", "[", "string", "]", "*", "regexp", ".", "Regexp", "{", "f", ".", "mu", ".", "RLock", "(", ")", "\n", "ret", ":=", "f", ".", "currentFilters", "\n", "f", ".", "mu", ".", "...
// GetFilters returns the currently used regex filters. Do not modify this map.
[ "GetFilters", "returns", "the", "currently", "used", "regex", "filters", ".", "Do", "not", "modify", "this", "map", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L128-L133
140,788
signalfx/golib
log/filter.go
SetFilters
func (f *RegexFilter) SetFilters(filters map[string]*regexp.Regexp) { f.Log.Log(FilterCount, len(filters), "Changing filters") f.mu.Lock() f.currentFilters = filters atomic.AddInt64(&f.filterChangeIndex, 1) f.mu.Unlock() }
go
func (f *RegexFilter) SetFilters(filters map[string]*regexp.Regexp) { f.Log.Log(FilterCount, len(filters), "Changing filters") f.mu.Lock() f.currentFilters = filters atomic.AddInt64(&f.filterChangeIndex, 1) f.mu.Unlock() }
[ "func", "(", "f", "*", "RegexFilter", ")", "SetFilters", "(", "filters", "map", "[", "string", "]", "*", "regexp", ".", "Regexp", ")", "{", "f", ".", "Log", ".", "Log", "(", "FilterCount", ",", "len", "(", "filters", ")", ",", "\"", "\"", ")", "\...
// SetFilters changes the internal regex map
[ "SetFilters", "changes", "the", "internal", "regex", "map" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/log/filter.go#L139-L145
140,789
signalfx/golib
sfxclient/rollbucket.go
NewRollingBucket
func NewRollingBucket(metricName string, dimensions map[string]string) *RollingBucket { return &RollingBucket{ MetricName: metricName, Dimensions: dimensions, Quantiles: DefaultQuantiles, BucketWidth: DefaultBucketWidth, Hist: gohistogram.NewHistogram(DefaultHist...
go
func NewRollingBucket(metricName string, dimensions map[string]string) *RollingBucket { return &RollingBucket{ MetricName: metricName, Dimensions: dimensions, Quantiles: DefaultQuantiles, BucketWidth: DefaultBucketWidth, Hist: gohistogram.NewHistogram(DefaultHist...
[ "func", "NewRollingBucket", "(", "metricName", "string", ",", "dimensions", "map", "[", "string", "]", "string", ")", "*", "RollingBucket", "{", "return", "&", "RollingBucket", "{", "MetricName", ":", "metricName", ",", "Dimensions", ":", "dimensions", ",", "Q...
// NewRollingBucket creates a new RollingBucket using default values for Quantiles, BucketWidth, // and the histogram tracker.
[ "NewRollingBucket", "creates", "a", "new", "RollingBucket", "using", "default", "values", "for", "Quantiles", "BucketWidth", "and", "the", "histogram", "tracker", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/rollbucket.go#L67-L77
140,790
signalfx/golib
sfxclient/rollbucket.go
AddAt
func (r *RollingBucket) AddAt(v float64, t time.Time) { r.mu.Lock() r.updateTime(t) if r.Hist.Count() == 0 { r.min = v r.max = v } else { r.min = math.Min(r.min, v) r.max = math.Max(r.max, v) } r.count++ r.sum += v r.sumOfSquares += v * v r.Hist.Add(v) r.mu.Unlock() }
go
func (r *RollingBucket) AddAt(v float64, t time.Time) { r.mu.Lock() r.updateTime(t) if r.Hist.Count() == 0 { r.min = v r.max = v } else { r.min = math.Min(r.min, v) r.max = math.Max(r.max, v) } r.count++ r.sum += v r.sumOfSquares += v * v r.Hist.Add(v) r.mu.Unlock() }
[ "func", "(", "r", "*", "RollingBucket", ")", "AddAt", "(", "v", "float64", ",", "t", "time", ".", "Time", ")", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "r", ".", "updateTime", "(", "t", ")", "\n\n", "if", "r", ".", "Hist", ".", "Coun...
// AddAt is like Add but also takes a time to pretend the value comes at.
[ "AddAt", "is", "like", "Add", "but", "also", "takes", "a", "time", "to", "pretend", "the", "value", "comes", "at", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/rollbucket.go#L172-L190
140,791
signalfx/golib
distconf/cmd.go
Cmd
func Cmd(prefix string) Reader { return &cmdDisco{ prefix: prefix, source: os.Args, } }
go
func Cmd(prefix string) Reader { return &cmdDisco{ prefix: prefix, source: os.Args, } }
[ "func", "Cmd", "(", "prefix", "string", ")", "Reader", "{", "return", "&", "cmdDisco", "{", "prefix", ":", "prefix", ",", "source", ":", "os", ".", "Args", ",", "}", "\n", "}" ]
// Cmd creates a backing reader that reads config varaibles from command line parameters with a prefix
[ "Cmd", "creates", "a", "backing", "reader", "that", "reads", "config", "varaibles", "from", "command", "line", "parameters", "with", "a", "prefix" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/distconf/cmd.go#L27-L32
140,792
signalfx/golib
distconf/cmd.go
CmdLoader
func CmdLoader(prefix string) BackingLoader { return BackingLoaderFunc(func() (Reader, error) { return Cmd(prefix), nil }) }
go
func CmdLoader(prefix string) BackingLoader { return BackingLoaderFunc(func() (Reader, error) { return Cmd(prefix), nil }) }
[ "func", "CmdLoader", "(", "prefix", "string", ")", "BackingLoader", "{", "return", "BackingLoaderFunc", "(", "func", "(", ")", "(", "Reader", ",", "error", ")", "{", "return", "Cmd", "(", "prefix", ")", ",", "nil", "\n", "}", ")", "\n", "}" ]
// CmdLoader is a loading helper for command line config variables
[ "CmdLoader", "is", "a", "loading", "helper", "for", "command", "line", "config", "variables" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/distconf/cmd.go#L35-L39
140,793
signalfx/golib
metadata/aws/ec2metadata/ec2.go
ToStringMap
func (e *EC2Metadata) ToStringMap() map[string]string { metadata := map[string]string{ "aws_availability_zone": e.AvailabilityZone, "aws_instance_type": e.InstanceType, "aws_instance_id": e.InstanceID, "aws_image_id": e.ImageID, "aws_account_id": e.AccountID, "aws_region": ...
go
func (e *EC2Metadata) ToStringMap() map[string]string { metadata := map[string]string{ "aws_availability_zone": e.AvailabilityZone, "aws_instance_type": e.InstanceType, "aws_instance_id": e.InstanceID, "aws_image_id": e.ImageID, "aws_account_id": e.AccountID, "aws_region": ...
[ "func", "(", "e", "*", "EC2Metadata", ")", "ToStringMap", "(", ")", "map", "[", "string", "]", "string", "{", "metadata", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "e", ".", "AvailabilityZone", ",", "\"", "\"", ":", "e", ".",...
// ToStringMap returns the ec2 metadata as a string map
[ "ToStringMap", "returns", "the", "ec2", "metadata", "as", "a", "string", "map" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/aws/ec2metadata/ec2.go#L46-L59
140,794
signalfx/golib
metadata/aws/ec2metadata/ec2.go
GetWithIdentityURL
func GetWithIdentityURL(url string) (*EC2Metadata, error) { metadata, err := requestAWSInfo(url) if err != nil { return metadata, errors.New("not an aws box") } if id, err := metadata.GetAWSUniqueID(); err == nil { metadata.AWSUniqueID = id } return metadata, nil }
go
func GetWithIdentityURL(url string) (*EC2Metadata, error) { metadata, err := requestAWSInfo(url) if err != nil { return metadata, errors.New("not an aws box") } if id, err := metadata.GetAWSUniqueID(); err == nil { metadata.AWSUniqueID = id } return metadata, nil }
[ "func", "GetWithIdentityURL", "(", "url", "string", ")", "(", "*", "EC2Metadata", ",", "error", ")", "{", "metadata", ",", "err", ":=", "requestAWSInfo", "(", "url", ")", "\n", "if", "err", "!=", "nil", "{", "return", "metadata", ",", "errors", ".", "N...
// GetWithIdentityURL returns a map with aws metadata including AWSUniqueID
[ "GetWithIdentityURL", "returns", "a", "map", "with", "aws", "metadata", "including", "AWSUniqueID" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/aws/ec2metadata/ec2.go#L67-L77
140,795
signalfx/golib
metadata/aws/ec2metadata/ec2.go
requestAWSInfo
func requestAWSInfo(url string) (metadata *EC2Metadata, err error) { metadata = &EC2Metadata{} httpClient := &http.Client{Timeout: 200 * time.Millisecond} // make the request var res *http.Response if res, err = httpClient.Get(url); err == nil { err = json.NewDecoder(res.Body).Decode(metadata) _ = res.Body.Cl...
go
func requestAWSInfo(url string) (metadata *EC2Metadata, err error) { metadata = &EC2Metadata{} httpClient := &http.Client{Timeout: 200 * time.Millisecond} // make the request var res *http.Response if res, err = httpClient.Get(url); err == nil { err = json.NewDecoder(res.Body).Decode(metadata) _ = res.Body.Cl...
[ "func", "requestAWSInfo", "(", "url", "string", ")", "(", "metadata", "*", "EC2Metadata", ",", "err", "error", ")", "{", "metadata", "=", "&", "EC2Metadata", "{", "}", "\n", "httpClient", ":=", "&", "http", ".", "Client", "{", "Timeout", ":", "200", "*...
// requestAWSInfo makes a request to the desired aws metadata url and decodes // the response into an EC2Metadata struct
[ "requestAWSInfo", "makes", "a", "request", "to", "the", "desired", "aws", "metadata", "url", "and", "decodes", "the", "response", "into", "an", "EC2Metadata", "struct" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/metadata/aws/ec2metadata/ec2.go#L81-L93
140,796
signalfx/golib
sfxclient/cumulativebucket.go
Add
func (r *Result) Add(val int64) { r.Count++ r.Sum += val // Sum of squares tends to roll over pretty easily r.SumOfSquares += float64(val) * float64(val) }
go
func (r *Result) Add(val int64) { r.Count++ r.Sum += val // Sum of squares tends to roll over pretty easily r.SumOfSquares += float64(val) * float64(val) }
[ "func", "(", "r", "*", "Result", ")", "Add", "(", "val", "int64", ")", "{", "r", ".", "Count", "++", "\n", "r", ".", "Sum", "+=", "val", "\n", "// Sum of squares tends to roll over pretty easily", "r", ".", "SumOfSquares", "+=", "float64", "(", "val", ")...
// Add a single number to the bucket. This does not use atomic operations and is not thread safe, // but adding a finished Result into a CumulativeBucket is thread safe.
[ "Add", "a", "single", "number", "to", "the", "bucket", ".", "This", "does", "not", "use", "atomic", "operations", "and", "is", "not", "thread", "safe", "but", "adding", "a", "finished", "Result", "into", "a", "CumulativeBucket", "is", "thread", "safe", "."...
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/cumulativebucket.go#L37-L42
140,797
signalfx/golib
sfxclient/cumulativebucket.go
Add
func (b *CumulativeBucket) Add(val int64) { r := &Result{} r.Add(val) b.MultiAdd(r) }
go
func (b *CumulativeBucket) Add(val int64) { r := &Result{} r.Add(val) b.MultiAdd(r) }
[ "func", "(", "b", "*", "CumulativeBucket", ")", "Add", "(", "val", "int64", ")", "{", "r", ":=", "&", "Result", "{", "}", "\n", "r", ".", "Add", "(", "val", ")", "\n", "b", ".", "MultiAdd", "(", "r", ")", "\n", "}" ]
// Add an item to the bucket, later reporting the result in the next report cycle.
[ "Add", "an", "item", "to", "the", "bucket", "later", "reporting", "the", "result", "in", "the", "next", "report", "cycle", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/cumulativebucket.go#L58-L62
140,798
signalfx/golib
sfxclient/cumulativebucket.go
MultiAdd
func (b *CumulativeBucket) MultiAdd(res *Result) { if res.Count == 0 { return } atomic.AddInt64(&b.count, res.Count) atomic.AddInt64(&b.sum, res.Sum) b.sumOfSquares.Add(res.SumOfSquares) }
go
func (b *CumulativeBucket) MultiAdd(res *Result) { if res.Count == 0 { return } atomic.AddInt64(&b.count, res.Count) atomic.AddInt64(&b.sum, res.Sum) b.sumOfSquares.Add(res.SumOfSquares) }
[ "func", "(", "b", "*", "CumulativeBucket", ")", "MultiAdd", "(", "res", "*", "Result", ")", "{", "if", "res", ".", "Count", "==", "0", "{", "return", "\n", "}", "\n", "atomic", ".", "AddInt64", "(", "&", "b", ".", "count", ",", "res", ".", "Count...
// MultiAdd many items into the bucket at once using a Result. This can be more efficient as it // involves only a constant number of atomic operations.
[ "MultiAdd", "many", "items", "into", "the", "bucket", "at", "once", "using", "a", "Result", ".", "This", "can", "be", "more", "efficient", "as", "it", "involves", "only", "a", "constant", "number", "of", "atomic", "operations", "." ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/sfxclient/cumulativebucket.go#L66-L73
140,799
signalfx/golib
httpdebug/server.go
New
func New(conf *Config) *Server { conf = pointer.FillDefaultFrom(conf, DefaultConfig).(*Config) m := http.NewServeMux() s := &Server{ Server: http.Server{ // TODO: Also put logger in http.Server Handler: m, ReadTimeout: *conf.ReadTimeout, WriteTimeout: *conf.WriteTimeout, }, Exp2: expvar2.New(...
go
func New(conf *Config) *Server { conf = pointer.FillDefaultFrom(conf, DefaultConfig).(*Config) m := http.NewServeMux() s := &Server{ Server: http.Server{ // TODO: Also put logger in http.Server Handler: m, ReadTimeout: *conf.ReadTimeout, WriteTimeout: *conf.WriteTimeout, }, Exp2: expvar2.New(...
[ "func", "New", "(", "conf", "*", "Config", ")", "*", "Server", "{", "conf", "=", "pointer", ".", "FillDefaultFrom", "(", "conf", ",", "DefaultConfig", ")", ".", "(", "*", "Config", ")", "\n", "m", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "...
// New creates a new debug server
[ "New", "creates", "a", "new", "debug", "server" ]
5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef
https://github.com/signalfx/golib/blob/5aa9ff46dab65ebcaaf1cee9c32b7d3e761ac6ef/httpdebug/server.go#L41-L69