Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add span format tag for jaeger-collector #1493

Merged
merged 4 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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