id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c13300 | += int64(sample) * int64(1/sampleRate)
} | |
c13301 | float64(c.value),
Tags: tags,
Type: CounterMetric,
Sinks: routeInfo(tags),
}}
} | |
c13302 | metricpb.Type_Counter,
Value: &metricpb.Metric_Counter{&metricpb.CounterValue{Value: c.value}},
}, nil
} | |
c13303 | {
c.value += v.Value
} | |
c13304 | &Counter{Name: Name, Tags: Tags}
} | |
c13305 | float64(g.value),
Tags: tags,
Type: GaugeMetric,
Sinks: routeInfo(tags),
}}
} | |
c13306 | JSONMetric{}, err
}
return JSONMetric{
MetricKey: MetricKey{
Name: g.Name,
Type: "gauge",
JoinedTags: strings.Join(g.Tags, ","),
},
Tags: g.Tags,
Value: buf.Bytes(),
}, nil
} | |
c13307 | metricpb.Type_Gauge,
Value: &metricpb.Metric_Gauge{&metricpb.GaugeValue{Value: g.value}},
}, nil
} | |
c13308 | {
g.value = v.Value
} | |
c13309 |
s.Type = StatusMetric
s.Sinks = routeInfo(s.Tags)
return []InterMetric{s.InterMetric}
} | |
c13310 | return JSONMetric{}, err
}
return JSONMetric{
MetricKey: MetricKey{
Name: s.Name,
Type: "status",
JoinedTags: strings.Join(s.Tags, ","),
},
Tags: s.Tags,
Value: buf.Bytes(),
}, nil
} | |
c13311 | s.Hll.Insert([]byte(sample))
} | |
c13312 |
// TODO: this is the maximum precision, should it be configurable?
Hll := hyperloglog.New()
return &Set{
Name: Name,
Tags: Tags,
Hll: Hll,
}
} | |
c13313 | float64(s.Hll.Estimate()),
Tags: tags,
Type: GaugeMetric,
Sinks: routeInfo(tags),
}}
} | |
c13314 | s.Name,
Type: "set",
JoinedTags: strings.Join(s.Tags, ","),
},
Tags: s.Tags,
Value: val,
}, nil
} | |
c13315 | Tags: s.Tags,
Type: metricpb.Type_Set,
Value: &metricpb.Metric_Set{&metricpb.SetValue{HyperLogLog: encoded}},
}, nil
} | |
c13316 | s.Combine(v.HyperLogLog)
} | |
c13317 | h.LocalMax = math.Max(h.LocalMax, sample)
h.LocalSum += sample * weight
h.LocalReciprocalSum += (1 / sample) * weight
} | |
c13318 | tdigest.NewMerging(100, false),
LocalMin: math.Inf(+1),
LocalMax: math.Inf(-1),
LocalSum: 0,
}
} | |
c13319 | h.Name,
Type: "histogram",
JoinedTags: strings.Join(h.Tags, ","),
},
Tags: h.Tags,
Value: val,
}, nil
} | |
c13320 | h.Tags,
Type: metricpb.Type_Histogram,
Value: &metricpb.Metric_Histogram{&metricpb.HistogramValue{
TDigest: h.Value.Data(),
}},
}, nil
} | |
c13321 |
h.Value.Merge(tdigest.NewMergingFromData(v.TDigest))
}
} | |
c13322 | return metricpb.Scope_Local
case GlobalOnly:
return metricpb.Scope_Global
}
return 0
} | |
c13323 | return LocalOnly
case metricpb.Scope_Mixed:
return MixedScope
}
return 0
} | |
c13324 | strings.ToLower(m.Type.String()),
JoinedTags: strings.Join(m.Tags, ","),
}
} | |
c13325 |
buff.WriteString(m.Type)
buff.WriteString(m.JoinedTags)
return buff.String()
} | |
c13326 | invalid = append(invalid, metricPacket)
continue
}
metrics = append(metrics, metric)
}
if len(invalid) != 0 {
return metrics, &invalidMetrics{invalid}
}
return metrics, nil
} | |
c13327 | ret = ret && sample.Value != nil
return ret
} | |
c13328 | }
ret.SampleRate = metric.SampleRate
tempTags := make([]string, 0, len(metric.Tags))
for key, value := range metric.Tags {
if key == "veneurlocalonly" {
ret.Scope = LocalOnly
continue
}
if key == "veneurglobalonly" {
ret.Scope = GlobalOnly
continue
}
tempTags = append(tempTags, key+":"+value)
... | |
c13329 | *options) {
opts.forwardTimeout = d
}
} | |
c13330 | *options) {
opts.log = e
}
} | |
c13331 | *options) {
opts.statsInterval = d
}
} | |
c13332 | *options) {
opts.traceClient = c
}
} | |
c13333 | TsvMetricType: metricType,
TsvInterval: strconv.Itoa(interval),
TsvVeneurHostname: hostName,
TsvValue: strconv.FormatFloat(metricValue, 'f', -1, 64),
TsvTimestamp: time.Unix(d.Timestamp, 0).UTC().Format(RedshiftDateFormat),
// TODO avoid edge case at midnight
TsvPartition: partitionDat... | |
c13334 | ioutil.Discard
res.opts.log = logrus.NewEntry(log)
}
if err := res.SetDestinations(destinations); err != nil {
return nil, fmt.Errorf("failed to set the destinations: %v", err)
}
forwardrpc.RegisterForwardServer(res.Server, res)
return res, nil
} | |
c13335 |
// create a connection for each destination
for _, dest := range new {
if err := s.conns.Add(dest); err != nil {
return fmt.Errorf("failed to setup a connection for the "+
"destination '%s': %v", dest, err)
}
}
s.destinations = dests
return nil
} | |
c13336 | 1)
_ = s.sendMetrics(context.Background(), mlist)
atomic.AddInt64(s.activeProxyHandlers, -1)
}()
return &empty.Empty{}, nil
} | |
c13337 | return "", fmt.Errorf("failed to hash the MetricKey '%s' to a "+
"destination: %v", key.String(), err)
}
return dest, nil
} | |
c13338 | err = c.SendMetrics(ctx, &forwardrpc.MetricList{Metrics: ms})
if err != nil {
return fmt.Errorf("failed to send %d metrics over gRPC: %v",
len(ms), err)
}
_ = metrics.ReportBatch(s.opts.traceClient, ssf.RandomlySample(0.1,
ssf.Count("metrics_by_destination", float32(len(ms)),
map[string]string{"destinati... | |
c13339 |
ssf.Gauge("proxy.active_goroutines", float32(atomic.LoadInt64(s.activeProxyHandlers)), globalProtocolTags))
} | |
c13340 | (cause=%s, metrics=%d): %v", e.msg, e.cause,
e.numMetrics, e.err)
} | |
c13341 | ssf.Count("proxy.proxied_metrics_failed", float32(e.numMetrics), tags),
ssf.Count("proxy.forward_errors", 1, tags),
)
} | |
c13342 | for i, err := range errs[:len(strs)] {
strs[i] = err.Error()
}
// If there are errors that weren't printed, add a message to the end
str := strings.Join(strs, "\n * ")
if len(strs) < len(errs) {
str += fmt.Sprintf("\nand %d more...", len(errs)-len(strs))
}
return str
} | |
c13343 | packetPool)
return b
default:
panic(fmt.Sprintf("Can't listen on %v: only TCP, UDP and unixgram:// are supported", a))
}
} | |
c13344 | if err != nil {
// if any goroutine fails to create the socket, we can't really
// recover, so we just blow up
// this probably indicates a systemic issue, eg lack of
// SO_REUSEPORT support
panic(fmt.Sprintf("couldn't listen on UDP socket %v: %v", addr, err))
}
// Pass the address that we ar... | |
c13345 | }
go func() {
defer func() {
lock.Unlock()
close(done)
}()
for {
_, open := <-s.shutdown
// occurs when cleanly shutting down the server e.g. in tests; ignore errors
if !open {
conn.Close()
return
}
}
}()
for i := 0; i < s.numReaders; i++ {
go s.ReadStatsdDatagramSocket(conn, pa... | |
c13346 | & unix:// are supported", a))
}
log.WithFields(logrus.Fields{
"address": a.String(),
"network": a.Network(),
}).Info("Listening for SSF traces")
return a
} | |
c13347 |
if err != nil {
select {
case <-s.shutdown:
// occurs when cleanly shutting down the server e.g. in tests; ignore errors
log.WithError(err).Info("Ignoring Accept error while shutting down")
return
default:
log.WithError(err).Fatal("Unix accept failed")
}
}
conns ... | |
c13348 | the lock %q to listen on %v: %v", lockname, addr, err))
}
if !locked {
panic(fmt.Sprintf("Lock file %q for %v is in use by another process already", lockname, addr))
}
// We have the exclusive use of the socket, clear away any old sockets and listen:
_ = os.Remove(addr.String())
return lock
} | |
c13349 |
clone := textMapReaderWriter(map[string]string{})
t.CloneTo(clone)
return clone
} | |
c13350 | string) error {
w.Set(k, v)
return nil
})
} | |
c13351 | nil {
// TODO handle err
return true
}
val = i
return false
}
return true
})
return val
} | |
c13352 | ResourceKey {
resource = v
return false
}
return true
})
return resource
} | |
c13353 | s.ClientFinishWithOptions(cl, opentracing.FinishOptions{
FinishTime: time.Now(),
LogRecords: nil,
BulkLogData: nil,
})
} | |
c13354 | s.ClientFinishWithOptions(DefaultClient, opts)
} | |
c13355 |
}
// TODO remove the name tag from the slice of tags
s.recordErr = s.ClientRecord(cl, s.Name, s.Tags)
} | |
c13356 | opentracing.Span {
s.Trace.Resource = name
return s
} | |
c13357 | fmt.Stringer:
val = v.String()
default:
// TODO maybe just ban non-strings?
val = fmt.Sprintf("%#v", value)
}
s.Tags[key] = val
return s
} | |
c13358 | opentracing.ContextWithSpan(ctx, s)
} | |
c13359 | {
// TODO mutex this
s.logLines = append(s.logLines, fields...)
} | |
c13360 | opentracing.Span {
s.contextAsParent().baggageItems[restrictedKey] = value
return s
} | |
c13361 | s.contextAsParent().baggageItems[restrictedKey]
} | |
c13362 | func(sso *opentracing.StartSpanOptions) {
sso.StartTime = t
},
}
} | |
c13363 | return tracer.InjectHeader(t, req.Header)
} | |
c13364 | tracer.Inject(t.context(), opentracing.HTTPHeaders, carrier)
} | |
c13365 | if err != nil {
return nil, err
}
parent := parentSpan.(*spanContext)
t := StartChildSpan(&Trace{
SpanID: parent.SpanID(),
TraceID: parent.TraceID(),
ParentID: parent.ParentID(),
Resource: resource,
})
t.Name = name
return &Span{
tracer: tracer,
Trace: t,
}, nil
} | |
c13366 | TsvTimestamp.String(),
TsvPartition: TsvPartition.String(),
}
w.Write(headers[:])
}
// TODO avoid edge case at midnight
partitionDate := time.Now()
for _, metric := range metrics {
EncodeInterMetricCSV(metric, w, &partitionDate, hostname, interval)
}
w.Flush()
gzw.Close()
return bytes.NewRead... | |
c13367 |
buf: buf,
delim: delim,
}
} | |
c13368 | no newline, consume the entire buffer
sb.currentChunk = sb.buf
sb.buf = nil
sb.lastChunk = true
} else {
sb.currentChunk = sb.buf[:next]
sb.buf = sb.buf[next+1:]
}
return true
} | |
c13369 | receive until the gRPC connection
// state changes. When it does, flip the marker over to allow another
// error to be logged from Ingest().
gs.grpcConn.WaitForStateChange(ocontext.Background(), gs.grpcConn.GetState())
atomic.StoreUint32(&gs.loggedSinceTransition, 0)
}
}()
return nil
} | |
c13370 | || atomic.CompareAndSwapUint32(&gs.loggedSinceTransition, 0, 1) {
gs.log.WithFields(logrus.Fields{
logrus.ErrorKey: err,
"target": gs.target,
"name": gs.name,
"chanstate": state.String(),
"code": serr.Code(),
"details": serr.Details(),
"message": ... | |
c13371 | c.authHeader()}
req.r, req.w = io.Pipe()
return req
} | |
c13372 |
return &httpClientTracer{
prefix: prefix,
traceClient: tc,
mutex: &sync.Mutex{},
ctx: ctx,
currentSpan: span,
}
} | |
c13373 | ConnectStart: hct.connectStart,
WroteHeaders: hct.wroteHeaders,
WroteRequest: hct.wroteRequest,
}
} | |
c13374 |
newSpan, _ := trace.StartSpanFromContext(hct.ctx, name)
hct.currentSpan.ClientFinish(hct.traceClient)
hct.currentSpan = newSpan
return newSpan
} | |
c13375 | hct.currentSpan.ClientFinish(hct.traceClient)
} | |
c13376 |
// Set the sample threshold to (sample rate) * (maximum value of uint32), so that
// we can store it as a uint32 instead of a float64 and compare apples-to-apples
// with the output of our hashing algorithm.
sampleThreshold = uint32(sampleRatePercentage * math.MaxUint32 / 100)
// Build a regex for cleaning name... | |
c13377 |
if err != nil {
return err
}
conn, err := net.DialUDP("udp", nil, xrayDaemon)
if err != nil {
return err
}
x.conn = conn
return nil
} | |
c13378 |
metrics.ReportBatch(x.traceClient, []*ssf.SSFSample{
ssf.Count(sinks.MetricKeyTotalSpansFlushed, float32(atomic.SwapInt64(&x.spansHandled, 0)), map[string]string{"sink": x.Name()}),
ssf.Count(sinks.MetricKeyTotalSpansDropped, float32(atomic.SwapInt64(&x.spansDropped, 0)), map[string]string{"sink": x.Name()}),
})... | |
c13379 | ReportBatch(cl, samples.Batch)
} | |
c13380 | error {
return ReportAsync(cl, samples, nil)
} | |
c13381 | ReportAsync(cl, []*ssf.SSFSample{metric}, nil)
} | |
c13382 | t.End = time.Now()
}
} | |
c13383 |
if t.End.IsZero() {
return -1
}
return t.End.Sub(t.Start)
} | |
c13384 | return err
}
_, err = w.Write(packet)
return err
} | |
c13385 | t.ClientRecord(DefaultClient, name, tags)
} | |
c13386 |
}
if name == "" {
name = t.Name
}
span := t.SSFSpan()
span.Name = name
return Record(cl, span, t.Sent)
} | |
c13387 | context.WithValue(c, traceKey, t)
} | |
c13388 | *traceID,
SpanID: *traceID,
ParentID: 0,
Resource: resource,
Tags: map[string]string{},
}
t.Start = time.Now()
return t
} | |
c13389 | }
span.SetParent(parent)
span.Start = time.Now()
return span
} | |
c13390 | eventTopic,
"metric_topic": metricTopic,
"partitioner": partitioner,
"ack_requirement": ackRequirement,
"max_retries": retries,
"buffer_bytes": bufferBytes,
"buffer_messages": bufferMessages,
"buffer_duration": bufferDuration,
}).Info("Created Kafka metric sink")
return &KafkaMetricSi... | |
c13391 | Kafka")
producer, err := sarama.NewAsyncProducer(brokerList, config)
if err != nil {
logger.Error("Error Connecting to Kafka. client error: ", err)
}
return producer, nil
} | |
c13392 | metric.Name)
samples.Add(ssf.Count("kafka.marshal.error_total", 1, nil))
return err
}
k.producer.Input() <- &sarama.ProducerMessage{
Topic: k.metricTopic,
Value: sarama.StringEncoder(j),
}
successes++
}
samples.Add(ssf.Count(sinks.MetricKeyTotalMetricsFlushed, float32(successes), map[string]stri... | |
c13393 | if bufferDuration != "" {
var err error
finalBufferDuration, err = time.ParseDuration(bufferDuration)
if err != nil {
return nil, err
}
}
config, _ := newProducerConfig(ll, ackRequirement, partitioner, retries, bufferBytes, bufferMessages, finalBufferDuration)
ll.WithFields(logrus.Fields{
"brokers": ... | |
c13394 | ssf.Count(sinks.MetricKeyTotalSpansFlushed, float32(atomic.LoadInt64(&k.spansFlushed)), map[string]string{"sink": k.Name()}))
atomic.SwapInt64(&k.spansFlushed, 0)
} | |
c13395 | &options{},
}
for _, opt := range opts {
opt(res.opts)
}
if res.opts.traceClient == nil {
res.opts.traceClient = trace.DefaultClient
}
forwardrpc.RegisterForwardServer(res.Server, res)
return res
} | |
c13396 | map[samplers.MetricKey]*samplers.Set{},
timers: map[samplers.MetricKey]*samplers.Histo{},
localHistograms: map[samplers.MetricKey]*samplers.Histo{},
localSets: map[samplers.MetricKey]*samplers.Set{},
localTimers: map[samplers.MetricKey]*samplers.Histo{},
localStatusChecks: ma... | |
c13397 | exp.GetName(),
}).Error("Could not export metric")
metrics.ReportOne(cl,
ssf.Count("worker_metrics.export_metric.errors", 1, map[string]string{
"type": mType.String(),
}),
)
return res
}
m.Type = mType
return append(res, m)
} | |
c13398 | 0,
mutex: &sync.Mutex{},
traceClient: cl,
logger: logger,
wm: NewWorkerMetrics(),
stats: stats,
}
} | |
c13399 | defer w.mutex.Unlock()
return w.processed
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.