Skip to content

Commit

Permalink
Add span format tag for jaeger-collector (#1493)
Browse files Browse the repository at this point in the history
include span format tag for every processed span in the collector

Signed-off-by: jung <[email protected]>
  • Loading branch information
guo0693 authored and yurishkuro committed Apr 25, 2019
1 parent 7a1f334 commit f86da0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmd/collector/app/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func (sp *spanProcessor) enqueueSpan(span *model.Span, originalFormat SpanFormat
spanCounts.RejectedBySvc.ReportServiceNameForSpan(span)
return true // as in "not dropped", because it's actively rejected
}

//add format tag
span.Tags = append(span.Tags, model.String("internal.span.format", string(originalFormat)))

item := &queueItem{
queuedTime: time.Now(),
span: span,
Expand Down
14 changes: 9 additions & 5 deletions model/converter/thrift/jaeger/to_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func (td toDomain) ToDomainSpan(jSpan *jaeger.Span, jProcess *jaeger.Process) *m

func (td toDomain) transformSpan(jSpan *jaeger.Span, mProcess *model.Process) *model.Span {
traceID := model.NewTraceID(uint64(jSpan.TraceIdHigh), uint64(jSpan.TraceIdLow))
tags := td.getTags(jSpan.Tags)
//allocate extra space for future append operation
tags := td.getTags(jSpan.Tags, 1)
refs := td.getReferences(jSpan.References)
// We no longer store ParentSpanID in the domain model, but the data in Thrift model
// might still have these IDs without representing them in the References, so we
Expand Down Expand Up @@ -104,18 +105,21 @@ func (td toDomain) getProcess(jProcess *jaeger.Process) *model.Process {
if jProcess == nil {
return nil
}
tags := td.getTags(jProcess.Tags)
tags := td.getTags(jProcess.Tags, 0)
return &model.Process{
Tags: tags,
ServiceName: jProcess.ServiceName,
}
}

func (td toDomain) getTags(tags []*jaeger.Tag) model.KeyValues {
//convert the jaeger.Tag slice to domain KeyValue slice
//zipkin/to_domain.go does not give a default slice size since it has to filter annotations, jaeger conversion is more predictable
//thus to avoid future full array copy when using append, pre-allocate extra space as an optimization
func (td toDomain) getTags(tags []*jaeger.Tag, extraSpace int) model.KeyValues {
if len(tags) == 0 {
return nil
}
retMe := make(model.KeyValues, len(tags))
retMe := make(model.KeyValues, len(tags), len(tags)+extraSpace)
for i, tag := range tags {
retMe[i] = td.getTag(tag)
}
Expand Down Expand Up @@ -147,7 +151,7 @@ func (td toDomain) getLogs(logs []*jaeger.Log) []model.Log {
for i, log := range logs {
retMe[i] = model.Log{
Timestamp: model.EpochMicrosecondsAsTime(uint64(log.Timestamp)),
Fields: td.getTags(log.Fields),
Fields: td.getTags(log.Fields, 0),
}
}
return retMe
Expand Down

0 comments on commit f86da0a

Please sign in to comment.