Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

Set x-ms-correlation-request-id #13520

Open jcaton-msft opened 3 years ago

jcaton-msft commented 3 years ago

Enable a way to get or set the Http request header x-ms-correlation-request-id

The ask is to provide a mechanism to set a value in the http header when a rest full call is made to ARM by a cmdlet invocation. We need a guarantee that all the restful calls associated with any cmdlet call will set the header if specified. Thus this invocation this will impact all cmdlets available that talk with ARM. Two invocations of the same cmdlet happening “at the same time” can have distinct values in the header. For now, we are looking to set the x-ms-correlation-request-id value in the header. Maybe they want to make it generic so we can pass a key/value pair and set other values later.

dingmeng-xue commented 3 years ago

@dolauli , please check if there is way to enable this feature on generated cmdlet. We don't hope to change cmdlet one by one.

ctaggart commented 3 years ago

@jcaton-msft, is this for instrumentation and tracing across services? According to the documentation, that is what x-ms-client-request-id is for.

x-ms-client-request-id: associated with a logical action in the client; e.g. loading the portal monitoring part may have a single client request id for many calls to ARM (e.g. load VMs + load metric definitions + load metrics) x-ms-correlation-request-id: associated with a logical action in ARM; e.g. deleting a resource group or running a template

dingmeng-xue commented 3 years ago

Change this title to x-ms-client-request-id. We are considering how to set it and meet the expectation.

ctaggart commented 3 years ago

BTW both headers are settable my clients. The documentation was updated to explain the purpose of both: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-details.md#client-request-headers

dingmeng-xue commented 3 years ago

We will consider to configure it using the similar way.

jcaton-msft commented 3 years ago

Circling back to see if this can be supported.

dingmeng-xue commented 3 years ago

Original, we'd like to support it by an environment variable which is common approach in Azure PowerShell. But it only supports a static value of client request id. I'm not sure the meaning of set of client request id in your requirement. I assume it is a set of ID with a fix pattern.

What's your thought on below approach? I haven't confirmed with others. But it is pretty close. Idea is that 2 variables allow client to manipulate ID per bit.

  1. Generate GUID IDA as what we have now
  2. IDB = IDA AND AZURE_PS_HTTP_CLIENT_REQUEST_ID_MASK
  3. IDC = IDB OR AZURE_PS_HTTP_CLIENT_REQUEST_ID

For instance Env: AZURE_PS_HTTP_CLIENT_REQUEST_ID = 12345678-0000-abcd-0000-000000000000 Env: AZURE_PS_HTTP_CLIENT_REQUEST_ID_MASK = 00000000-0000-0000-ffff-ffffffffffff

IDA = 9c8ea296-a370-4799-a6f6-e4118539822a IDB = 00000000-0000-0000-ffff-ffffffffffff AND 9c8ea296-a370-4799-a6f6-e4118539822a = 00000000-0000-0000-a6f6-e4118539822a IDC = 00000000-0000-0000-a6f6-e4118539822a OR 12345678-0000-abcd-0000-000000000000 = 12345678-0000-abcd-a6f6-e4118539822a

ghost commented 3 years ago

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

jcaton-msft commented 3 years ago

Hmm... not sure why this would be closed by the msftbot but there is an active discussion going on internally in MS for this so we would like to keep it open.