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

Integrate HttpClientFactory and metrics #86888

Merged
merged 6 commits into from
Aug 7, 2023

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented May 30, 2023

Prototype for integration between HttpClientFactory and metrics

  • Set Meter on handler from IMeterFactory (waiting for API on handler)

Note: HttpClient doesn't have metrics yet, so this PR is useless by itself. @antonfirsov is working on that. In this PR I want to experiment with designing everything end-to-end so we have an idea of what a user of HttpClient metrics APIs will look like.

@ghost
Copy link

ghost commented May 30, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Prototype for integration between HttpClientFactory and metrics

  • Set Meter on handler from IMeterFactory
  • HttpClientFactory extension methods for enrichment.
    • Support registering a callback or type.
    • Add internal DelegatingHandler that sets enrichment properties onto HttpRequestMessage.
Author: JamesNK
Assignees: -
Labels:

area-Extensions-HttpClientFactory

Milestone: -

@JamesNK
Copy link
Member Author

JamesNK commented May 30, 2023

@tarekgh
Copy link
Member

tarekgh commented May 30, 2023

Change LGTM, I added a small question to the review.

@ghost ghost closed this Jun 30, 2023
@ghost
Copy link

ghost commented Jun 30, 2023

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@karelz karelz added this to the 8.0.0 milestone Jul 3, 2023
@JamesNK JamesNK reopened this Jul 31, 2023
@JamesNK
Copy link
Member Author

JamesNK commented Jul 31, 2023

@karelz @CarnaViire @antonfirsov @noahfalk This is still to do. It needs to happen for .NET 8. I don't think this had its own issue. It might have been a checkbox or paragraph in another issue.

I'll rebase this PR, react to API changes, unmark as draft, and ping for reviews.

@JamesNK JamesNK marked this pull request as ready for review August 1, 2023 00:25
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.

👍

// The MeterFactory property is available on handlers in .NET 8 or later.
if (PrimaryHandler is HttpClientHandler httpClientHandler)
{
httpClientHandler.MeterFactory = _meterFactory;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure DefaultHttpMessageHandlerBuilder is a correct place to hardcode this injection...

Why it's not a ConfigurePrimaryHandler action added via ConfigureHttpClientDefaults or, at least, ConfigureAll?

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 updated it to use a filter.

Defaults or configure don't work because the meter factory should be applied last. If someone changes the handler, such as to a SocketsHttpHandler, then we want to apply the meter factory after that change.

@JamesNK
Copy link
Member Author

JamesNK commented Aug 7, 2023

@CarnaViire Please review and merge if good.

Copy link
Member

@CarnaViire CarnaViire left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@CarnaViire CarnaViire left a comment

Choose a reason for hiding this comment

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

Test failures are related @JamesNK. From a brief look they are PNSE, meaning we need a ConditionalFact

@ghost ghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Aug 7, 2023
@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Aug 7, 2023
@CarnaViire CarnaViire merged commit f4b0610 into dotnet:main Aug 7, 2023
103 checks passed
@ghost ghost locked as resolved and limited conversation to collaborators Sep 6, 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.

6 participants