Skip to content

Commit e7447c9

Browse files
committed
docs(readme): add infomration on setting global transaction id
1 parent a25086b commit e7447c9

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ private void OnMessage(DetailedResponse<MessageResponse> response, IBMError erro
402402
```
403403

404404
## Transaction IDs
405-
Every SDK call returns a response with a transaction ID in the x-global-transaction-id header. This transaction ID is useful for troubleshooting and accessing relevant logs from your service instance.
405+
Every SDK call returns a response with a transaction ID in the X-Global-Transaction-Id header. Together the service instance region, this ID helps support teams troubleshoot issues from relevant logs.
406406

407407
```cs
408408
public void ExampleGetTransactionId()
@@ -413,11 +413,34 @@ public void ExampleGetTransactionId()
413413
{
414414
if(error != null)
415415
{
416-
Log.Debug("AssistantServiceV1", "Transaction Id: {0}", error.ResponseHeaders["x-global-transaction-id"]);
416+
Log.Debug("AssistantServiceV1", "Transaction Id: {0}", error.ResponseHeaders["X-Global-Transaction-Id"]);
417417
}
418418
else
419419
{
420-
Log.Debug("AssistantServiceV1", "Transaction Id: {0}", response.Headers["x-global-transaction-id"]);
420+
Log.Debug("AssistantServiceV1", "Transaction Id: {0}", response.Headers["X-Global-Transaction-Id"]);
421+
}
422+
}
423+
);
424+
}
425+
```
426+
427+
However, the transaction ID isn't available when the API doesn't return a response for some reason. In that case, you can set your own transaction ID in the request. For example, replace <my-unique-transaction-id> in the following example with a unique transaction ID.
428+
429+
```cs
430+
public void ExampleSetTransactionId()
431+
{
432+
AssistantService service = new AssistantService("{version-date}");
433+
service.WithHeader("X-Global-Transaction-Id", "<my-unique-transaction-id>");
434+
service.ListWorkspaces(
435+
callback: (DetailedResponse<Workspace> response, IBMError error) =>
436+
{
437+
if(error != null)
438+
{
439+
Log.Debug("AssistantServiceV1", "Transaction Id: {0}", error.ResponseHeaders["X-Global-Transaction-Id"]);
440+
}
441+
else
442+
{
443+
Log.Debug("AssistantServiceV1", "Transaction Id: {0}", response.Headers["X-Global-Transaction-Id"]);
421444
}
422445
}
423446
);

0 commit comments

Comments
 (0)