microsoft / dotnet-podcasts

.NET reference application shown at .NET Conf featuring ASP.NET Core, Blazor, .NET MAUI, Microservices, Orleans, Playwright, and more!
https://dot.net
MIT License
2.75k stars 745 forks source link

Delaying Task at JitterHandler #209

Closed etcetera33 closed 1 year ago

etcetera33 commented 1 year ago

JitterHandler waits for some time before performing an action.

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            // Who would do such a thing?!
            // TODO fix this horrible perf leak!
            await Task.Delay(TimeSpan.FromMilliseconds(Random.Shared.NextInt64(50, 500)));
            return await base.SendAsync(request, cancellationToken);
        }

Can I be assigned to this one, please?

And if there are any additional details about this (as it feels like) workaround, please, share.

jamesmontemagno commented 1 year ago

@baronfel i think added this for a demo..... Should we now remove this or comment it out?

etcetera33 commented 1 year ago

@baronfel if that is the case, I will gladly comment it out, or better - remove the JitterHandler so that the DelegatingHandlers` SendAsync() is executed without delays. Waiting for your decision!

cc @jamesmontemagno

baronfel commented 1 year ago

Sorry about the delay! Yes, the JitterHandler was introduced so that the OpenTelemetry spans for the calls would be noticable. Without it things happen too dang quick to show in traces! #justdotnetproblems

I think for the real demo app that customers would use, it can be deleted.

etcetera33 commented 1 year ago

Sorry about the delay! Yes, the JitterHandler was introduced so that the OpenTelemetry spans for the calls would be noticable. Without it things happen too dang quick to show in traces! #justdotnetproblems

I think for the real demo app that customers would use, it can be deleted.

No worries! I`ve posted a PR with the fix, so if you will have a minute, I would really appreciate you looking at it!