-
Notifications
You must be signed in to change notification settings - Fork 784
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
Fix bug with multiple views mapping to a single metric stream #3006
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3006 +/- ##
==========================================
+ Coverage 84.66% 84.77% +0.10%
==========================================
Files 259 260 +1
Lines 9228 9273 +45
==========================================
+ Hits 7813 7861 +48
+ Misses 1415 1412 -3
|
} | ||
} | ||
|
||
public readonly string MeterName { get; } |
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.
I don't think we need readonly
on all the members because the struct itself is readonly
. Any harm in having it? Nothing major that I can think of. Might lead to a bigger binary, I'm assuming readonly
ends up a hint in the IL metadata. More code to maintain 😄
|
||
namespace OpenTelemetry.Metrics | ||
{ | ||
internal class StringArrayEqualityComparer : IEqualityComparer<string[]> |
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.
@alanwest I just took a quick look, I think there might be some runtime bits we can use for these array comparers. Check out this fiddle:
using System;
using System.Collections;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string[] first = new string[] { "one", "two", "three" };
string[] second = new string[] { "one", "two", "three" };
string[] third = new string[] { "one", "two", "THREE" };
Console.WriteLine(((IStructuralEquatable)first).Equals(second, StringComparer.Ordinal));
Console.WriteLine(((IStructuralEquatable)first).Equals(third, StringComparer.Ordinal));
Console.WriteLine(((IStructuralEquatable)first).Equals(third, StringComparer.OrdinalIgnoreCase));
double[] firstD = new double[] { 0.18D, 1D, 0.99D };
double[] secondD = new double[] { 0.18D, 1D, 0.99D };
Console.WriteLine(((IStructuralEquatable)firstD).Equals(secondD, EqualityComparer<double>.Default));
}
}
It looks like Array has this hidden (explicitly implemented) IStructuralEquatable we might be able to use.
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.
Cool I like this. From looking at reference source looks like Array has implemented IStructuralEquatable for quite some time.
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.
I reverted my change to use IStructuralEquatable. Unit tests were failing only for net461. I haven't dug into why. I'd like to follow up with trying out IStructureEquatable in a separate PR because it definitely does simplify the code.
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
3bfed37
to
931ea28
Compare
Merging this. There are a few follow ups coming soon.
|
My original implementation from #2916 did not correctly handle some cases when using views.