Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

Why does SetDefaultAgentInfo exist in Microsoft.Rest.ClientRuntime? #10020

Closed collinstevens closed 3 years ago

collinstevens commented 4 years ago

Query/Question Why does SetDefaultAgentInfo exist in Microsoft.Rest.ClientRuntime?

This is appending the name type name of our AutoRest clients which use ServiceClient as base class to the UserAgent of the HttpClient given to the AutoRest client. We also share a single HttpClient across multiple AutoRest clients which causes a chain of type names in the UserAgent. There seems to be no way to opt out of this behavior from looking at the source.

If I am using the constructor which takes an HttpClient, I shoud be able to opt-out of this behavior or it shouldn't do it in the first place.

Environment: Microsoft.Rest.ClientRuntime.2.3.20\lib\net461\Microsoft.Rest.ClientRuntime.dll

isra-fel commented 4 years ago

Sorry for late response. @collinstevens Hi Collin could you share your code sample, the expected hehavior, and the actual behavior with us? Thanks

collinstevens commented 4 years ago

@isra-fel I don't have an issue with the usage of the API; I'm asking for documentation as to why the ServiceClient performs this operation and preferably a way to opt out of it.

allenjzhang commented 3 years ago

User agent header allows us to categorize client library info to aid better support and SDK retirement decisions. There is no PII information in it. If you really want to override it, you can pass in a DelegatingHandler similar to this to override.

var wsmClient = new WebSiteManagementClient(cred, new DelegatingHandler[] { new UserAgentDelegatingHandler() })

Also, we are working on the new Azure.Core based management SDKs. This library will only be updated for critical and security fixes at this point. If you have a similar request/suggestion for Azure.Core, please open a separate feature request. Thanks!