Azure / autorest.typescript

Extension for AutoRest (https://github.com/Azure/autorest) that generates TypeScript code. The transpiled javascript code is isomorphic. It can be run in browser and in node.js environment.
MIT License
177 stars 73 forks source link

Set user agent at different layers for modular #2616

Open timovv opened 1 week ago

timovv commented 1 week ago

Update user agent to change depending on which layer is being used (TODO: update these to add -modular)

The azsdk-js- prefix is omitted for unflavored packages.

Problem: RLC currently concatenates the passed in userAgentPrefix so we may get long user agents like azsdk-js-<packageName>-api/<version> azsdk-js-<packagename>-rest/<version>

Implement user agent string as defined in this Loop:

For a package @azure/my-library version 1.0.0:

  • Requests from the REST layer will have user agent prefix azsdk-js-my-library/1.0.0
  • Requests from the API layer will have user agent prefix azsdk-js-api azsdk-js-my-library/1.0.0
  • Requests from the client layer will have user agent prefix azsdk-js-client azsdk-js-api azsdk-js-my-library/1.0.0
timovv commented 1 week ago

I had a discussion with Jose about this and we settled on the following format for the user agent:

We need to prepend at each layer here since the REST layer concatenates the passed in userAgentPrefix to its value (the prefix can't be overridden). Changing this behavior would make it possible for customers to override the user agent value entirely which I believe we want to avoid. So instead of substituting the value based on which layer is being used, we prepend an extra value for each layer instead.

@qiaozha, @MaryGao, any issues with the above proposal? One remaining question I have: for the "classic" level, do we want to call this "classic" or "client"? No strong opinion here.

MaryGao commented 1 week ago

@qiaozha, @MaryGao, any issues with the above proposal? One remaining question I have: for the "classic" level, do we want to call this "classic" or "client"? No strong opinion here.

Before digging into detailed patterns I may ask if we still plan to split the RLC from Modular https://github.com/Azure/autorest.typescript/issues/1981. If yes, I don't think we have the ability to distingush if a RLC is initiated from Modular or normal usage. In that way the RLC would be always like azsdk-js-<packageName>-rest/<version>.

qiaozha commented 1 week ago

@qiaozha, @MaryGao, any issues with the above proposal? One remaining question I have: for the "classic" level, do we want to call this "classic" or "client"? No strong opinion here.

Before digging into detailed patterns I may ask if we still plan to split the RLC from Modular #1981. If yes, I don't think we have the ability to distingush if a RLC is initiated from Modular or normal usage. In that way the RLC would be always like azsdk-js-<packageName>-rest/<version>.

I also noticed this, I left a comment before for the PR description, but then I delete it because of that.

joheredi commented 3 days ago

I think it is valid to think about when we split RLC from modular. But at this point we don't have a clear plan on how that is going to happen, and there are a couple of ways it can go. I think we should go with this PR and take a change if needed before GA