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

Improve request ID for custom header name #30771

Merged
merged 21 commits into from
Jun 17, 2023
Merged

Improve request ID for custom header name #30771

merged 21 commits into from
Jun 17, 2023

Conversation

lmazuel
Copy link
Member

@lmazuel lmazuel commented Jun 14, 2023

  • Add a kwarg to request id policy to set the header name (similar to what Java is already doing)
  • Add requst id policy in config, for easier setting by codegen

@lmazuel lmazuel marked this pull request as ready for review June 14, 2023 16:53
@lmazuel lmazuel linked an issue Jun 14, 2023 that may be closed by this pull request
Copy link
Member

@xiangyan99 xiangyan99 left a comment

Choose a reason for hiding this comment

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

LGTM

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-core

@lmazuel lmazuel merged commit 9efde13 into main Jun 17, 2023
@lmazuel lmazuel deleted the request_id_update branch June 17, 2023 23:47
MaryGao added a commit to Azure/azure-sdk-for-js that referenced this pull request Jul 12, 2023
…ines (#26424)

### Packages impacted by this PR
@azure/core-rest-pipeline

### Issues associated with this PR

Azure/autorest.typescript#1906 (comment)

### Describe the problem that is addressed by this PR

Batch service has the requirement to custom their request id header to
`client-request-id` ([tsp
here](https://github.com/Azure/azure-rest-api-specs/blob/b37ad7f957f0c6f9dd149546e46399308f83b366/specification/batch/Batch/routes.tsp#L2719-L2727)).
Currently the header name is fixed as default value
`x-ms-client-request-id` in setClientRequestIdPolicy.

So I think we could open an option in PipelineOptions to allow
customizing this header.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?

Another option to support this is to add a customized policy from SDK
side, to achieve that we could:
- remove the default setClientRequestIdPolicy
- re-add a new setClientRequestIdPolicy policy and set the header with
customized name

Compared to the latter one I think the current implementation would be
more generic and elegant and can easily apply to more cases in future.
But I'm also open for better options.

### References

- Azure/azure-sdk-for-python#30771

---------

Co-authored-by: Jeff Fisher <xirzec@xirzec.com>
dgetu pushed a commit to Azure/azure-sdk-for-js that referenced this pull request Sep 6, 2023
…ines (#26424)

### Packages impacted by this PR
@azure/core-rest-pipeline

### Issues associated with this PR

Azure/autorest.typescript#1906 (comment)

### Describe the problem that is addressed by this PR

Batch service has the requirement to custom their request id header to
`client-request-id` ([tsp
here](https://github.com/Azure/azure-rest-api-specs/blob/b37ad7f957f0c6f9dd149546e46399308f83b366/specification/batch/Batch/routes.tsp#L2719-L2727)).
Currently the header name is fixed as default value
`x-ms-client-request-id` in setClientRequestIdPolicy.

So I think we could open an option in PipelineOptions to allow
customizing this header.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?

Another option to support this is to add a customized policy from SDK
side, to achieve that we could:
- remove the default setClientRequestIdPolicy
- re-add a new setClientRequestIdPolicy policy and set the header with
customized name

Compared to the latter one I think the current implementation would be
more generic and elegant and can easily apply to more cases in future.
But I'm also open for better options.

### References

- Azure/azure-sdk-for-python#30771

---------

Co-authored-by: Jeff Fisher <xirzec@xirzec.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make RequestIDPolicy header name as a parameter
5 participants