Skip to content

Add support for retries with Polly #43942

Open
@chertby

Description

@chertby

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

No response

Describe the solution you'd like

Currently, if you configure retrays using AddTransientHttpErrorPolicy, there will be no traces if the request will retray.
Even if you add the OpenTelemetry.Instrumentation.Http, only the first request will be visible in the traces, and subsequent attempts will not be displayed in any way.

This is because Polly is configured with an extension to retry the SendCoreAsync method in the PolicyHttpMessageHandler class.

esponse = await policy.ExecuteAsync((c, ct) => SendCoreAsync(request, c, ct), context, cancellationToken).ConfigureAwait(false);

Whereas right now activities are created at a higher level in the HttpClient class.

Additional context

I propose to extend the PolicyHttpMessageHandler class: add the creation of a span to it when a request is made. And also add the RetryAttempt property to the Polly.Context class so that we can fill in the tags according to the OpenTelemetry convention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-httpclientfactoryIncludes: HttpClientFactory (some bugs also in Extensions repo)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions