-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 metrics configuration APIs #90201
Conversation
src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/DebugConsoleMetricListener.cs
Outdated
Show resolved
Hide resolved
return; | ||
} | ||
|
||
if (_instruments.TryGetValue(instrument, out var _)) |
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 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.
That's not available on all of our TFMs.
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.
Can polyfill this I guess the same way we do like
Line 15 in 79b9707
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ReferenceEqualityComparer.cs" /> |
src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs
Outdated
Show resolved
Hide resolved
|
||
var ruleMeterName = rule.MeterName.AsSpan(); | ||
// Rule "System.Net.*" matches meter "System.Net" and "System.Net.Http" | ||
if (ruleMeterName.EndsWith(".*".AsSpan(), StringComparison.Ordinal)) |
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 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.
Being discussed over at #90201 (comment)
src/libraries/Microsoft.Extensions.Diagnostics/src/Metrics/ListenerSubscription.cs
Outdated
Show resolved
Hide resolved
/// </summary> | ||
public MeterScope Scopes { get; } = scopes == MeterScope.None | ||
? throw new ArgumentOutOfRangeException(nameof(scopes), scopes, "The MeterScope must be Global, Local, or both.") | ||
: scopes; |
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 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'm mostly worried about the common case where someone passes in None by mistake. If they want to deliberately pass in other values I'm not going to question them too closely 😁.
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 have a strong opinion here but would prefer to communicate the failure sooner instead of having the user see unexpected behavior later and it will be hard to investigate.
.../Microsoft.Extensions.Diagnostics.Abstractions/src/Metrics/MetricsBuilderExtensions.Rules.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Hosting/ref/Microsoft.Extensions.Hosting.cs
Outdated
Show resolved
Hide resolved
...es/Microsoft.Extensions.Diagnostics.Abstractions/tests/MetricsBuilderExtensionsRulesTests.cs
Show resolved
Hide resolved
Poor @carlosalberto. He always gets tagged by @tarekgh instead of me. 😄 |
Sorry @carlosalberto, I promise will be more careful next 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'm marking approved so we can get this into RC1. The vast majority looks good but I still disagree with the inconsistent behavior for string matching between metrics and logging. Chris is out tomorrow so any changes there will need to happen in RC2.
<!-- Disabling baseline validation since this is a brand new package. | ||
Once this package has shipped a stable version, the following line | ||
should be removed in order to re-enable validation. --> | ||
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation> |
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.
Should an issue be created to track that?
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.
We scan all libraries for this and remove it. @ViktorHofer may advise if we need to track individual libraries.
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.
No tracking issue needed. We do this every year around December when the previous .NET version has released. We have this written down in a OneNote.
Contributes to #85684.
This adds a set of new APIs used to configure metrics and which listeners they should be paired with. The API closely follows the design from logging.
One new package is added, Microsoft.Extensions.Diagnostics.Abstractions.
The components in the Microsoft.Extensions.Diagnostics.Configuration namespace will be implemented in a later PR.
The goal is to have this merged by Thursday afternoon.