-
Notifications
You must be signed in to change notification settings - Fork 774
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
Added GetTagValue Activity Extension #1221
Added GetTagValue Activity Extension #1221
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1221 +/- ##
==========================================
+ Coverage 78.76% 78.81% +0.04%
==========================================
Files 219 219
Lines 6311 6329 +18
==========================================
+ Hits 4971 4988 +17
- Misses 1340 1341 +1
|
Don't know how hard is, but we could add another test using |
/// <param name="tagName">Case-sensitive tag name to retrieve.</param> | ||
/// <returns>Tag value or null if a match was not found.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static object GetTagValue(this Activity activity, string tagName) |
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.
Curious - I wonder if there are many scenarios where people would try to get multiple tag values. If yes, a further improvement might be giving a GetTagValues overload (which takes an array/list of names and a ref to Span or something allocated on the stack).
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.
There's actually a method a few lines up doing two lookups! 1 for status code, 1 for status description. I'll take a stab at this later. If the PR gets merged I'll do as a follow-up.
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.
LGTM!
Update: I found the spots using Linq in the main solution and updated them to use the extension. So it is now providing immediate value. I was looking for TagObjects, they were using Tags. 🙄 |
I tried, and it is really hard! The one we did for setting kind on Activity, we knew both types (Activity & ActivityKind). The enumeration stuff is a whole different ballgame because you don't know the concrete type or the enumerator type it uses. All you really know is it is an I'm not convinced it is impossible to do using expression syntax, it's just going to take some time to figure it out. If you have any ideas please share! Maybe on Gitter so we don't spam this? |
All the struct enumerators I worked with the .NET team to introduce are available in RC1 so now we can have some fun with the perf.
Changes
This adds a GetTagValue extension on Activity for finding a tag value by key very efficiently.
Benchmarks
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes