12 Nov 2024 03:53 PM - edited 12 Nov 2024 03:54 PM
Afternoon community,
we currently host a mobile Maui app for which we'd like to implement auto instrumentation.
I think part of the auto-instrumentation is Step number 5 mentioned in the doc (Enabling automatic web request instrumentation )
The dev implementing this is using httpclient factory which brings complexity in implementing the suggestion in Step 5.
Has anyone experienced such complexity and how did you solve this?
Regards
Solved! Go to Solution.
14 Nov 2024 08:24 AM - edited 14 Nov 2024 08:25 AM
I don't have direct experience with the HttpClientFactory, but documentation shows how to create the HttpMessageHandler.
and in your documentation example about the usage of HttpClientFactory I can see the following:
builder.Services.AddHttpClient();
So I would assume the following usage:
builder.Services.AddHttpClient()
.ConfigureHttpMessageHandler(() => {
return Agent.Instance.GetHttpMessageHandler();
});
or
builder.Services.AddHttpClient()
.ConfigureHttpMessageHandlerBuilder((builder) => {
builder.PrimaryHandler = Agent.Instance.GetHttpMessageHandler();
builder.Build();
});