Skip to content
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

Merged
merged 50 commits into from
Aug 11, 2023
Merged

Add metrics configuration APIs #90201

merged 50 commits into from
Aug 11, 2023

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Aug 8, 2023

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.

return;
}

if (_instruments.TryGetValue(instrument, out var _))
Copy link
Member

Choose a reason for hiding this comment

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

(_instruments.TryGetValue(instrument, out var _))

Should we ensure the dictionary is created with reference equality comparer? In the future there may be added equality support to the instrument which possibly can make two instruments with the same name/descriptions be equal.

Copy link
Member Author

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.

Copy link
Member

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

<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ReferenceEqualityComparer.cs" />


var ruleMeterName = rule.MeterName.AsSpan();
// Rule "System.Net.*" matches meter "System.Net" and "System.Net.Http"
if (ruleMeterName.EndsWith(".*".AsSpan(), StringComparison.Ordinal))
Copy link
Member

Choose a reason for hiding this comment

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

if (ruleMeterName.EndsWith(".*".AsSpan(), StringComparison.Ordinal))

what happen if someone specify the rule .* only? would it be ok to have this equal to the rule with empty string or * only? I think this may be confusing.

Copy link
Member Author

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)

/// </summary>
public MeterScope Scopes { get; } = scopes == MeterScope.None
? throw new ArgumentOutOfRangeException(nameof(scopes), scopes, "The MeterScope must be Global, Local, or both.")
: scopes;
Copy link
Member

Choose a reason for hiding this comment

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

scopes;

should we validate this if someone added more unsupported values? or we don't care?

Copy link
Member Author

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 😁.

Copy link
Member

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.

@carlossanlop
Copy link
Member

carlossanlop commented Aug 10, 2023

CC @gewarren @carlosalberto

Poor @carlosalberto. He always gets tagged by @tarekgh instead of me. 😄

@tarekgh
Copy link
Member

tarekgh commented Aug 10, 2023

Poor @carlosalberto. He always gets tagged by @tarekgh Tarek Mahmoud Sayed FTE instead of me. 😄

Sorry @carlosalberto, I promise will be more careful next time.

Copy link
Member

@noahfalk noahfalk left a 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.

@noahfalk noahfalk merged commit 786b987 into dotnet:main Aug 11, 2023
104 checks passed
@tarekgh
Copy link
Member

tarekgh commented Aug 11, 2023

@noahfalk @Tratcher we still have Monday if we need to do anything more before RC1 snap.

<!-- 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>
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Member

@ViktorHofer ViktorHofer Aug 17, 2023

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.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants