Skip to content

Commit

Permalink
[distributed sampling] introduced DistributedSampled span member
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoot committed Sep 27, 2017
1 parent 7b1f4bd commit 7c03c51
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tracer/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ type Span struct {
ParentID uint64 `json:"parent_id"` // identifier of the span's direct parent
Error int32 `json:"error"` // error status of the span; 0 means no errors
Sampled bool `json:"-"` // if this span is sampled (and should be kept/recorded) or not
// Ideally we would put distributed_sampled on root spans only. But this requires either
// writing the marshaller manually or use hacky "hiding" of the field,
// see http://attilaolah.eu/2014/09/10/json-and-struct-composition-in-go/ on how to do this.
// For now, keep it as is, send it all the time, it's minor network overhead.
DistributedSampled bool `json:"distributed_sampled"` // if this span is sampled (as in distributed tracing, all parts must be kept) or not

sync.RWMutex
tracer *Tracer // the tracer that generated this span
Expand All @@ -72,16 +77,17 @@ type Span struct {
// Most of the time one should prefer the Tracer NewRootSpan or NewChildSpan methods.
func NewSpan(name, service, resource string, spanID, traceID, parentID uint64, tracer *Tracer) *Span {
return &Span{
Name: name,
Service: service,
Resource: resource,
Meta: tracer.getAllMeta(),
SpanID: spanID,
TraceID: traceID,
ParentID: parentID,
Start: now(),
Sampled: true,
tracer: tracer,
Name: name,
Service: service,
Resource: resource,
Meta: tracer.getAllMeta(),
SpanID: spanID,
TraceID: traceID,
ParentID: parentID,
Start: now(),
Sampled: true,
DistributedSampled: true,
tracer: tracer,
}
}

Expand Down

0 comments on commit 7c03c51

Please sign in to comment.