Skip to content
Closed
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion translator/trace/jaeger/traces_to_jaegerproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func resourceToJaegerProtoProcess(resource pdata.Resource) *model.Process {
process := model.Process{}
if serviceName, ok := attrs.Get(conventions.AttributeServiceName); ok {
process.ServiceName = serviceName.StringVal()
attrs.Delete(conventions.AttributeServiceName)
}
process.Tags = attributesToJaegerProtoTags(attrs)
return &process
Expand All @@ -131,6 +130,10 @@ func attributesToJaegerProtoTags(attrs pdata.AttributeMap) []model.KeyValue {

tags := make([]model.KeyValue, 0, attrs.Cap())
attrs.ForEach(func(key string, attr pdata.AttributeValue) {
if key == conventions.AttributeServiceName {
return
}
Copy link
Member

@dmitryax dmitryax Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing it!

The only concern I have is that now we scatter handling of conventions.AttributeServiceName across many functions, it doesn't seem right especially having attributesToJaegerProtoTags function being called in other places. Probably we could add another argument to attributesToJaegerProtoTags like skipKeys map[string]bool that can be used to filter particular keys out. What do you think?

cc @tigrannajaryan

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributesToJaegerProtoTags is used in several places, so it makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like this. Map lookup is going to have cost. Translation functions need to be fast, and this one loop is the most frequently called one. I would like to see performance profile before accepting this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think map lookups should be pretty fast. map initialization is the most expensive, but here it's handled perfectly, only two initializations. Otherwise we can just duplicate the function and create resourceAttributesToJaegerProtoTags for now in order to not block the fix. @tigrannajaryan what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want a quick fix let's pass a single bool parameter that controls AttributeServiceName specifically.

If we want the map I can be easily convinced by a CPU profile that shows it is not significant. :-)


tag := model.KeyValue{Key: key}
switch attr.Type() {
case pdata.AttributeValueSTRING:
Expand Down