Update go dependencies
This commit is contained in:
parent
14a9e9f3fa
commit
14f4a7b8e8
1349 changed files with 128369 additions and 32627 deletions
9
vendor/go.opencensus.io/trace/basetypes.go
generated
vendored
9
vendor/go.opencensus.io/trace/basetypes.go
generated
vendored
|
|
@ -59,6 +59,11 @@ func Int64Attribute(key string, value int64) Attribute {
|
|||
return Attribute{key: key, value: value}
|
||||
}
|
||||
|
||||
// Float64Attribute returns a float64-valued attribute.
|
||||
func Float64Attribute(key string, value float64) Attribute {
|
||||
return Attribute{key: key, value: value}
|
||||
}
|
||||
|
||||
// StringAttribute returns a string-valued attribute.
|
||||
func StringAttribute(key string, value string) Attribute {
|
||||
return Attribute{key: key, value: value}
|
||||
|
|
@ -71,8 +76,8 @@ type LinkType int32
|
|||
// LinkType values.
|
||||
const (
|
||||
LinkTypeUnspecified LinkType = iota // The relationship of the two spans is unknown.
|
||||
LinkTypeChild // The current span is a child of the linked span.
|
||||
LinkTypeParent // The current span is the parent of the linked span.
|
||||
LinkTypeChild // The linked span is a child of the current span.
|
||||
LinkTypeParent // The linked span is the parent of the current span.
|
||||
)
|
||||
|
||||
// Link represents a reference from one span to another span.
|
||||
|
|
|
|||
38
vendor/go.opencensus.io/trace/config.go
generated
vendored
38
vendor/go.opencensus.io/trace/config.go
generated
vendored
|
|
@ -27,10 +27,36 @@ type Config struct {
|
|||
|
||||
// IDGenerator is for internal use only.
|
||||
IDGenerator internal.IDGenerator
|
||||
|
||||
// MaxAnnotationEventsPerSpan is max number of annotation events per span
|
||||
MaxAnnotationEventsPerSpan int
|
||||
|
||||
// MaxMessageEventsPerSpan is max number of message events per span
|
||||
MaxMessageEventsPerSpan int
|
||||
|
||||
// MaxAnnotationEventsPerSpan is max number of attributes per span
|
||||
MaxAttributesPerSpan int
|
||||
|
||||
// MaxLinksPerSpan is max number of links per span
|
||||
MaxLinksPerSpan int
|
||||
}
|
||||
|
||||
var configWriteMu sync.Mutex
|
||||
|
||||
const (
|
||||
// DefaultMaxAnnotationEventsPerSpan is default max number of annotation events per span
|
||||
DefaultMaxAnnotationEventsPerSpan = 32
|
||||
|
||||
// DefaultMaxMessageEventsPerSpan is default max number of message events per span
|
||||
DefaultMaxMessageEventsPerSpan = 128
|
||||
|
||||
// DefaultMaxAttributesPerSpan is default max number of attributes per span
|
||||
DefaultMaxAttributesPerSpan = 32
|
||||
|
||||
// DefaultMaxLinksPerSpan is default max number of links per span
|
||||
DefaultMaxLinksPerSpan = 32
|
||||
)
|
||||
|
||||
// ApplyConfig applies changes to the global tracing configuration.
|
||||
//
|
||||
// Fields not provided in the given config are going to be preserved.
|
||||
|
|
@ -44,5 +70,17 @@ func ApplyConfig(cfg Config) {
|
|||
if cfg.IDGenerator != nil {
|
||||
c.IDGenerator = cfg.IDGenerator
|
||||
}
|
||||
if cfg.MaxAnnotationEventsPerSpan > 0 {
|
||||
c.MaxAnnotationEventsPerSpan = cfg.MaxAnnotationEventsPerSpan
|
||||
}
|
||||
if cfg.MaxMessageEventsPerSpan > 0 {
|
||||
c.MaxMessageEventsPerSpan = cfg.MaxMessageEventsPerSpan
|
||||
}
|
||||
if cfg.MaxAttributesPerSpan > 0 {
|
||||
c.MaxAttributesPerSpan = cfg.MaxAttributesPerSpan
|
||||
}
|
||||
if cfg.MaxLinksPerSpan > 0 {
|
||||
c.MaxLinksPerSpan = cfg.MaxLinksPerSpan
|
||||
}
|
||||
config.Store(&c)
|
||||
}
|
||||
|
|
|
|||
38
vendor/go.opencensus.io/trace/evictedqueue.go
generated
vendored
Normal file
38
vendor/go.opencensus.io/trace/evictedqueue.go
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2019, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package trace
|
||||
|
||||
type evictedQueue struct {
|
||||
queue []interface{}
|
||||
capacity int
|
||||
droppedCount int
|
||||
}
|
||||
|
||||
func newEvictedQueue(capacity int) *evictedQueue {
|
||||
eq := &evictedQueue{
|
||||
capacity: capacity,
|
||||
queue: make([]interface{}, 0),
|
||||
}
|
||||
|
||||
return eq
|
||||
}
|
||||
|
||||
func (eq *evictedQueue) add(value interface{}) {
|
||||
if len(eq.queue) == eq.capacity {
|
||||
eq.queue = eq.queue[1:]
|
||||
eq.droppedCount++
|
||||
}
|
||||
eq.queue = append(eq.queue, value)
|
||||
}
|
||||
11
vendor/go.opencensus.io/trace/export.go
generated
vendored
11
vendor/go.opencensus.io/trace/export.go
generated
vendored
|
|
@ -85,6 +85,13 @@ type SpanData struct {
|
|||
Annotations []Annotation
|
||||
MessageEvents []MessageEvent
|
||||
Status
|
||||
Links []Link
|
||||
HasRemoteParent bool
|
||||
Links []Link
|
||||
HasRemoteParent bool
|
||||
DroppedAttributeCount int
|
||||
DroppedAnnotationCount int
|
||||
DroppedMessageEventCount int
|
||||
DroppedLinkCount int
|
||||
|
||||
// ChildSpanCount holds the number of child span created for this span.
|
||||
ChildSpanCount int
|
||||
}
|
||||
|
|
|
|||
1
vendor/go.opencensus.io/trace/internal/internal.go
generated
vendored
1
vendor/go.opencensus.io/trace/internal/internal.go
generated
vendored
|
|
@ -15,6 +15,7 @@
|
|||
// Package internal provides trace internals.
|
||||
package internal
|
||||
|
||||
// IDGenerator allows custom generators for TraceId and SpanId.
|
||||
type IDGenerator interface {
|
||||
NewTraceID() [16]byte
|
||||
NewSpanID() [8]byte
|
||||
|
|
|
|||
37
vendor/go.opencensus.io/trace/lrumap.go
generated
vendored
Normal file
37
vendor/go.opencensus.io/trace/lrumap.go
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2019, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package trace
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/golang-lru/simplelru"
|
||||
)
|
||||
|
||||
type lruMap struct {
|
||||
simpleLruMap *simplelru.LRU
|
||||
droppedCount int
|
||||
}
|
||||
|
||||
func newLruMap(size int) *lruMap {
|
||||
lm := &lruMap{}
|
||||
lm.simpleLruMap, _ = simplelru.NewLRU(size, nil)
|
||||
return lm
|
||||
}
|
||||
|
||||
func (lm *lruMap) add(key, value interface{}) {
|
||||
evicted := lm.simpleLruMap.Add(key, value)
|
||||
if evicted {
|
||||
lm.droppedCount++
|
||||
}
|
||||
}
|
||||
114
vendor/go.opencensus.io/trace/trace.go
generated
vendored
114
vendor/go.opencensus.io/trace/trace.go
generated
vendored
|
|
@ -42,6 +42,20 @@ type Span struct {
|
|||
data *SpanData
|
||||
mu sync.Mutex // protects the contents of *data (but not the pointer value.)
|
||||
spanContext SpanContext
|
||||
|
||||
// lruAttributes are capped at configured limit. When the capacity is reached an oldest entry
|
||||
// is removed to create room for a new entry.
|
||||
lruAttributes *lruMap
|
||||
|
||||
// annotations are stored in FIFO queue capped by configured limit.
|
||||
annotations *evictedQueue
|
||||
|
||||
// messageEvents are stored in FIFO queue capped by configured limit.
|
||||
messageEvents *evictedQueue
|
||||
|
||||
// links are stored in FIFO queue capped by configured limit.
|
||||
links *evictedQueue
|
||||
|
||||
// spanStore is the spanStore this span belongs to, if any, otherwise it is nil.
|
||||
*spanStore
|
||||
endOnce sync.Once
|
||||
|
|
@ -156,6 +170,7 @@ func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Cont
|
|||
var opts StartOptions
|
||||
var parent SpanContext
|
||||
if p := FromContext(ctx); p != nil {
|
||||
p.addChild()
|
||||
parent = p.spanContext
|
||||
}
|
||||
for _, op := range o {
|
||||
|
|
@ -226,6 +241,11 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa
|
|||
Name: name,
|
||||
HasRemoteParent: remoteParent,
|
||||
}
|
||||
span.lruAttributes = newLruMap(cfg.MaxAttributesPerSpan)
|
||||
span.annotations = newEvictedQueue(cfg.MaxAnnotationEventsPerSpan)
|
||||
span.messageEvents = newEvictedQueue(cfg.MaxMessageEventsPerSpan)
|
||||
span.links = newEvictedQueue(cfg.MaxLinksPerSpan)
|
||||
|
||||
if hasParent {
|
||||
span.data.ParentSpanID = parent.SpanID
|
||||
}
|
||||
|
|
@ -276,11 +296,21 @@ func (s *Span) makeSpanData() *SpanData {
|
|||
var sd SpanData
|
||||
s.mu.Lock()
|
||||
sd = *s.data
|
||||
if s.data.Attributes != nil {
|
||||
sd.Attributes = make(map[string]interface{})
|
||||
for k, v := range s.data.Attributes {
|
||||
sd.Attributes[k] = v
|
||||
}
|
||||
if s.lruAttributes.simpleLruMap.Len() > 0 {
|
||||
sd.Attributes = s.lruAttributesToAttributeMap()
|
||||
sd.DroppedAttributeCount = s.lruAttributes.droppedCount
|
||||
}
|
||||
if len(s.annotations.queue) > 0 {
|
||||
sd.Annotations = s.interfaceArrayToAnnotationArray()
|
||||
sd.DroppedAnnotationCount = s.annotations.droppedCount
|
||||
}
|
||||
if len(s.messageEvents.queue) > 0 {
|
||||
sd.MessageEvents = s.interfaceArrayToMessageEventArray()
|
||||
sd.DroppedMessageEventCount = s.messageEvents.droppedCount
|
||||
}
|
||||
if len(s.links.queue) > 0 {
|
||||
sd.Links = s.interfaceArrayToLinksArray()
|
||||
sd.DroppedLinkCount = s.links.droppedCount
|
||||
}
|
||||
s.mu.Unlock()
|
||||
return &sd
|
||||
|
|
@ -314,6 +344,57 @@ func (s *Span) SetStatus(status Status) {
|
|||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
func (s *Span) interfaceArrayToLinksArray() []Link {
|
||||
linksArr := make([]Link, 0)
|
||||
for _, value := range s.links.queue {
|
||||
linksArr = append(linksArr, value.(Link))
|
||||
}
|
||||
return linksArr
|
||||
}
|
||||
|
||||
func (s *Span) interfaceArrayToMessageEventArray() []MessageEvent {
|
||||
messageEventArr := make([]MessageEvent, 0)
|
||||
for _, value := range s.messageEvents.queue {
|
||||
messageEventArr = append(messageEventArr, value.(MessageEvent))
|
||||
}
|
||||
return messageEventArr
|
||||
}
|
||||
|
||||
func (s *Span) interfaceArrayToAnnotationArray() []Annotation {
|
||||
annotationArr := make([]Annotation, 0)
|
||||
for _, value := range s.annotations.queue {
|
||||
annotationArr = append(annotationArr, value.(Annotation))
|
||||
}
|
||||
return annotationArr
|
||||
}
|
||||
|
||||
func (s *Span) lruAttributesToAttributeMap() map[string]interface{} {
|
||||
attributes := make(map[string]interface{})
|
||||
for _, key := range s.lruAttributes.simpleLruMap.Keys() {
|
||||
value, ok := s.lruAttributes.simpleLruMap.Get(key)
|
||||
if ok {
|
||||
keyStr := key.(string)
|
||||
attributes[keyStr] = value
|
||||
}
|
||||
}
|
||||
return attributes
|
||||
}
|
||||
|
||||
func (s *Span) copyToCappedAttributes(attributes []Attribute) {
|
||||
for _, a := range attributes {
|
||||
s.lruAttributes.add(a.key, a.value)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Span) addChild() {
|
||||
if !s.IsRecordingEvents() {
|
||||
return
|
||||
}
|
||||
s.mu.Lock()
|
||||
s.data.ChildSpanCount++
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// AddAttributes sets attributes in the span.
|
||||
//
|
||||
// Existing attributes whose keys appear in the attributes parameter are overwritten.
|
||||
|
|
@ -322,10 +403,7 @@ func (s *Span) AddAttributes(attributes ...Attribute) {
|
|||
return
|
||||
}
|
||||
s.mu.Lock()
|
||||
if s.data.Attributes == nil {
|
||||
s.data.Attributes = make(map[string]interface{})
|
||||
}
|
||||
copyAttributes(s.data.Attributes, attributes)
|
||||
s.copyToCappedAttributes(attributes)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +423,7 @@ func (s *Span) lazyPrintfInternal(attributes []Attribute, format string, a ...in
|
|||
m = make(map[string]interface{})
|
||||
copyAttributes(m, attributes)
|
||||
}
|
||||
s.data.Annotations = append(s.data.Annotations, Annotation{
|
||||
s.annotations.add(Annotation{
|
||||
Time: now,
|
||||
Message: msg,
|
||||
Attributes: m,
|
||||
|
|
@ -361,7 +439,7 @@ func (s *Span) printStringInternal(attributes []Attribute, str string) {
|
|||
a = make(map[string]interface{})
|
||||
copyAttributes(a, attributes)
|
||||
}
|
||||
s.data.Annotations = append(s.data.Annotations, Annotation{
|
||||
s.annotations.add(Annotation{
|
||||
Time: now,
|
||||
Message: str,
|
||||
Attributes: a,
|
||||
|
|
@ -398,7 +476,7 @@ func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedBy
|
|||
}
|
||||
now := time.Now()
|
||||
s.mu.Lock()
|
||||
s.data.MessageEvents = append(s.data.MessageEvents, MessageEvent{
|
||||
s.messageEvents.add(MessageEvent{
|
||||
Time: now,
|
||||
EventType: MessageEventTypeSent,
|
||||
MessageID: messageID,
|
||||
|
|
@ -420,7 +498,7 @@ func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compresse
|
|||
}
|
||||
now := time.Now()
|
||||
s.mu.Lock()
|
||||
s.data.MessageEvents = append(s.data.MessageEvents, MessageEvent{
|
||||
s.messageEvents.add(MessageEvent{
|
||||
Time: now,
|
||||
EventType: MessageEventTypeRecv,
|
||||
MessageID: messageID,
|
||||
|
|
@ -436,7 +514,7 @@ func (s *Span) AddLink(l Link) {
|
|||
return
|
||||
}
|
||||
s.mu.Lock()
|
||||
s.data.Links = append(s.data.Links, l)
|
||||
s.links.add(l)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
|
|
@ -468,8 +546,12 @@ func init() {
|
|||
gen.spanIDInc |= 1
|
||||
|
||||
config.Store(&Config{
|
||||
DefaultSampler: ProbabilitySampler(defaultSamplingProbability),
|
||||
IDGenerator: gen,
|
||||
DefaultSampler: ProbabilitySampler(defaultSamplingProbability),
|
||||
IDGenerator: gen,
|
||||
MaxAttributesPerSpan: DefaultMaxAttributesPerSpan,
|
||||
MaxAnnotationEventsPerSpan: DefaultMaxAnnotationEventsPerSpan,
|
||||
MaxMessageEventsPerSpan: DefaultMaxMessageEventsPerSpan,
|
||||
MaxLinksPerSpan: DefaultMaxLinksPerSpan,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue