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

[Bug] MeasureDurationResult incorrect when running in linux #4784

Closed
SingleCopy opened this issue May 23, 2024 · 3 comments · Fixed by #4785
Closed

[Bug] MeasureDurationResult incorrect when running in linux #4784

SingleCopy opened this issue May 23, 2024 · 3 comments · Fixed by #4785

Comments

@SingleCopy
Copy link
Contributor

SingleCopy commented May 23, 2024

Library version used

4.60.3

.NET version

C# .net 8.0

Scenario

ManagedIdentityClient - managed identity

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

When our unit tests are run using a linux distro, the AuthenticationResult->AuthenticationResultMetadata->DurationTotalInMs is returning a incorrect time. This is due to the Stopwatch.Frequency being 10000000 on windows and 1000000000 on linux, this is not taken into account when performing the calculation.

Relevant code snippets

public MeasureDurationResult(long ticks)
{
    Milliseconds = ticks / TimeSpan.TicksPerMillisecond;
    Microseconds = ticks / (TimeSpan.TicksPerMillisecond / 1000);
    Ticks = ticks;
}

Expected behavior

Regardless of O/S, the DurationTotalInMs should be the same, however, on linux, the DurationTotalInMs is incorrect

Windows:
ElapsedTicks: 8423086
DurationTotalInMs: 842

Linux
ElapsedTicks: 8423086
DurationTotalInMs: 84230

Identity provider

Other

Regression

No response

Solution and workarounds

No response

@SingleCopy SingleCopy added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels May 23, 2024
@SingleCopy SingleCopy changed the title [Bug] DurationTotalInMs incorrect when running in linux [Bug] MeasureDurationResult incorrect when running in linux May 23, 2024
@gladjohn gladjohn added bug P2 scenario:ManagedIdentity and removed untriaged Do not delete. Needed for Automation needs attention Delete label after triage labels May 23, 2024
@localden
Copy link
Collaborator

@SingleCopy just to confirm, is this for Managed Identity? Because you're calling out ADFS as the Identity Provider later.

@localden
Copy link
Collaborator

Sounds like we need to update the converstion factor (1000.0 / Stopwatch.Frequency).

@SingleCopy
Copy link
Contributor Author

@localden Correct, this is for Managed Identity, I have updated my description.

@bgavrilMS bgavrilMS added this to the 4.62.0 milestone May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
4 participants