-
Notifications
You must be signed in to change notification settings - Fork 772
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
Updating exporters to use TagObjects instead of Tags #1000
Merged
cijothomas
merged 8 commits into
open-telemetry:master
from
eddynaka:feature/updating-zipking-newactivity
Aug 5, 2020
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
967ddc3
Update ZipkinExporter to use TagObjects instead of Tags
eddynaka 4afde9d
Updating JaegerExporter to use TagObjects
eddynaka 01ef4f4
Updating OtlpExporter to use TagObjects
eddynaka 2e2dc19
removing unused using
eddynaka 886ec49
Removing duplicated logic
eddynaka b70b799
Merge branch 'master' into feature/updating-zipking-newactivity
eddynaka e8f94f5
Merge branch 'master' into feature/updating-zipking-newactivity
eddynaka 2cb7d48
Merge branch 'master' into feature/updating-zipking-newactivity
cijothomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,11 @@ internal static class JaegerActivityExtensions | |
[SemanticConventions.AttributeNetPeerIp] = 2, | ||
["peer.hostname"] = 2, | ||
["peer.address"] = 2, | ||
["http.host"] = 3, // peer.service for Http. | ||
["db.instance"] = 3, // peer.service for Redis. | ||
[SemanticConventions.AttributeHttpHost] = 3, // peer.service for Http. | ||
[SemanticConventions.AttributeDbInstance] = 3, // peer.service for Redis. | ||
}; | ||
|
||
private static readonly DictionaryEnumerator<string, string, TagState>.ForEachDelegate ProcessActivityTagRef = ProcessActivityTag; | ||
private static readonly DictionaryEnumerator<string, object, TagState>.ForEachDelegate ProcessActivityTagRef = ProcessActivityTag; | ||
private static readonly ListEnumerator<ActivityLink, PooledListState<JaegerSpanRef>>.ForEachDelegate ProcessActivityLinkRef = ProcessActivityLink; | ||
private static readonly ListEnumerator<ActivityEvent, PooledListState<JaegerLog>>.ForEachDelegate ProcessActivityEventRef = ProcessActivityEvent; | ||
private static readonly DictionaryEnumerator<string, object, PooledListState<JaegerTag>>.ForEachDelegate ProcessTagRef = ProcessTag; | ||
|
@@ -64,8 +64,8 @@ public static JaegerSpan ToJaegerSpan(this Activity activity) | |
Tags = PooledList<JaegerTag>.Create(), | ||
}; | ||
|
||
DictionaryEnumerator<string, string, TagState>.AllocationFreeForEach( | ||
activity.Tags, | ||
DictionaryEnumerator<string, object, TagState>.AllocationFreeForEach( | ||
activity.TagObjects, | ||
ref jaegerTags, | ||
ProcessActivityTagRef); | ||
|
||
|
@@ -217,23 +217,16 @@ public static JaegerSpanRef ToJaegerSpanRef(this in ActivityLink link) | |
|
||
public static JaegerTag ToJaegerTag(this KeyValuePair<string, object> attribute) | ||
{ | ||
switch (attribute.Value) | ||
return attribute.Value switch | ||
{ | ||
case string s: | ||
return new JaegerTag(attribute.Key, JaegerTagType.STRING, vStr: s); | ||
case int i: | ||
return new JaegerTag(attribute.Key, JaegerTagType.LONG, vLong: Convert.ToInt64(i)); | ||
case long l: | ||
return new JaegerTag(attribute.Key, JaegerTagType.LONG, vLong: l); | ||
case float f: | ||
return new JaegerTag(attribute.Key, JaegerTagType.DOUBLE, vDouble: Convert.ToDouble(f)); | ||
case double d: | ||
return new JaegerTag(attribute.Key, JaegerTagType.DOUBLE, vDouble: d); | ||
case bool b: | ||
return new JaegerTag(attribute.Key, JaegerTagType.BOOL, vBool: b); | ||
} | ||
|
||
return new JaegerTag(attribute.Key, JaegerTagType.STRING, vStr: attribute.Value.ToString()); | ||
string s => new JaegerTag(attribute.Key, JaegerTagType.STRING, vStr: s), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we now need to deal with the array of primitives since #999 is merged. |
||
int i => new JaegerTag(attribute.Key, JaegerTagType.LONG, vLong: Convert.ToInt64(i)), | ||
long l => new JaegerTag(attribute.Key, JaegerTagType.LONG, vLong: l), | ||
float f => new JaegerTag(attribute.Key, JaegerTagType.DOUBLE, vDouble: Convert.ToDouble(f)), | ||
double d => new JaegerTag(attribute.Key, JaegerTagType.DOUBLE, vDouble: d), | ||
bool b => new JaegerTag(attribute.Key, JaegerTagType.BOOL, vBool: b), | ||
_ => new JaegerTag(attribute.Key, JaegerTagType.STRING, vStr: attribute.Value.ToString()), | ||
}; | ||
} | ||
|
||
public static long ToEpochMicroseconds(this DateTime utcDateTime) | ||
|
@@ -256,9 +249,9 @@ public static long ToEpochMicroseconds(this DateTimeOffset timestamp) | |
return microseconds - UnixEpochMicroseconds; | ||
} | ||
|
||
private static bool ProcessActivityTag(ref TagState state, KeyValuePair<string, string> activityTag) | ||
private static bool ProcessActivityTag(ref TagState state, KeyValuePair<string, object> activityTag) | ||
{ | ||
var jaegerTag = new JaegerTag(activityTag.Key, JaegerTagType.STRING, activityTag.Value); | ||
JaegerTag jaegerTag = activityTag.ToJaegerTag(); | ||
|
||
if (jaegerTag.VStr != null | ||
&& PeerServiceKeyResolutionDictionary.TryGetValue(activityTag.Key, out int priority) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarekgh Just noticing Activity.TagObjects uses a custom LinkedList and not ActivityTagsCollection like ActivityEvent & ActivityLink use. Because of that, no struct enumerator, perf regression for us anytime we enumerate TagObjects. Is there a compelling reason for the difference? What we really need is for whatever is underneath the IEnumerable returned to have a
struct GetEnumerator()
operation so we can foreach without allocation.Something like...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something can look at to optimize as everything is implementation details. I didn't change anything from what we used to have. Note that this will be a little bit tricky because it is possible some tags get removed while someone else enumerating the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome this would help a lot. When I say perf regression I mean moving from our old Span object to using Activity to drive everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are interested, you may submit a PR for that? we can work out the details together if you want.
CC @noahfalk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarekgh Done dotnet/runtime#40362