Skip to content

Commit 20d3316

Browse files
authored
Merge pull request #87 from watson-developer-cloud/docs/transaction-id
docs: add instructions to get transaction id
2 parents a03a48c + bbc5f9e commit 20d3316

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,28 @@ Headers: "<http response headers>"
267267
Result: "<response returned by service>"
268268
```
269269

270+
### Transaction IDs
271+
272+
Every SDK call will return a response which will contain a transaction ID, accessible via the `x-global-transaction-id` header. This transaction ID is useful for troubleshooting and accessing relevant logs from your service instance.
273+
274+
```ruby
275+
require "ibm_watson"
276+
include IBMWatson
277+
278+
assistant = AssistantV1.new(
279+
authenticator: "<authenticator>"
280+
version: "2017-04-21"
281+
)
282+
283+
begin
284+
response = assistant.list_workspaces
285+
p "Global transaction id: #{response.headers["X-Global-Transaction-Id"]}"
286+
rescue IBMCloudSdkCore::ApiException => e
287+
# Global transaction on failed api call is contained in the error message
288+
print "Error: ##{e}"
289+
end
290+
```
291+
270292
## Configuring the HTTP client
271293

272294
To set client configs like timeout or proxy use the `configure_http_client` function and pass in the configurations.
@@ -399,4 +421,4 @@ We'd love to highlight cool open-source projects that use this SDK! If you'd lik
399421
[license]: http://www.apache.org/licenses/LICENSE-2.0
400422
[vcap_services]: https://cloud.ibm.com/docs/services/watson?topic=watson-vcapServices
401423
[ibm-cloud-onboarding]: http://cloud.ibm.com/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Ruby
402-
[ivar]: http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html
424+
[ivar]: http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html

ibm_watson.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
3636
spec.add_runtime_dependency "eventmachine", "~> 1.2"
3737
spec.add_runtime_dependency "faye-websocket", "~> 0.10"
3838
spec.add_runtime_dependency "http", "~> 4.1.0"
39-
spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 1.1"
39+
spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 1.1.1"
4040
spec.add_runtime_dependency "jwt", "~> 2.2.1"
4141

4242
spec.add_development_dependency "bundler", "~> 1.16"

resources/vcap-testing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"credentials": {
55
"password": "password",
6-
"url": "https://gateway.watsonplatform.net/personality-insights/api",
6+
"url": "https://gateway-wdc.watsonplatform.net/personality-insights/api",
77
"username": "username"
88
},
99
"label": "personality",

test/unit/test_personality_insights_v3.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def test_plain_to_json
3333
version: "2017-10-13",
3434
authenticator: authenticator
3535
)
36+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
3637
service_response = service.profile(
3738
accept: "application/json",
3839
content: personality_text,
@@ -88,6 +89,7 @@ def test_json_to_json
8889
version: "2017-10-13",
8990
authenticator: authenticator
9091
)
92+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
9193
service_response = service.profile(
9294
accept: "application/json",
9395
content: personality_text,
@@ -128,6 +130,7 @@ def test_json_to_csv
128130
version: "2017-10-13",
129131
authenticator: authenticator
130132
)
133+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
131134
service_response = service.profile(
132135
content: personality_text,
133136
content_type: "application/json",
@@ -171,6 +174,7 @@ def test_plain_to_json_es
171174
version: "2017-10-13",
172175
authenticator: authenticator
173176
)
177+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
174178
service_response = service.profile(
175179
accept: "application/json",
176180
content: personality_text,

test/unit/test_vcap_using_personality_insights.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ def test_plain_to_json
1717
"Content-Type" => "application/json"
1818
}
1919
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: JSON.parse(profile_response), headers: headers)
20-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
20+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
2121
.with(
2222
body: personality_text,
2323
headers: {
2424
"Accept" => "application/json",
2525
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
2626
"Content-Type" => "text/plain;charset=utf-8",
27-
"Host" => "gateway.watsonplatform.net"
27+
"Host" => "gateway-wdc.watsonplatform.net"
2828
}
2929
).to_return(status: 200, body: profile_response, headers: headers)
3030
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
@@ -52,14 +52,14 @@ def test_json_to_json
5252
"Content-Type" => "applicaiton/json"
5353
}
5454
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
55-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&raw_scores=true&version=2017-10-13")
55+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&raw_scores=true&version=2017-10-13")
5656
.with(
5757
body: personality_text,
5858
headers: {
5959
"Accept" => "application/json",
6060
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
6161
"Content-Type" => "application/json",
62-
"Host" => "gateway.watsonplatform.net"
62+
"Host" => "gateway-wdc.watsonplatform.net"
6363
}
6464
).to_return(status: 200, body: profile_response, headers: headers)
6565
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
@@ -89,14 +89,14 @@ def test_json_to_csv
8989
"Content-Type" => "text/csv"
9090
}
9191
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
92-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&csv_headers=true&raw_scores=true&version=2017-10-13")
92+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&csv_headers=true&raw_scores=true&version=2017-10-13")
9393
.with(
9494
body: personality_text,
9595
headers: {
9696
"Accept" => "text/csv",
9797
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
9898
"Content-Type" => "application/json",
99-
"Host" => "gateway.watsonplatform.net"
99+
"Host" => "gateway-wdc.watsonplatform.net"
100100
}
101101
).to_return(status: 200, body: profile_response, headers: headers)
102102
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
@@ -127,7 +127,7 @@ def test_plain_to_json_es
127127
"Content-Type" => "application/json"
128128
}
129129
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
130-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
130+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
131131
.with(
132132
body: personality_text,
133133
headers: {
@@ -136,7 +136,7 @@ def test_plain_to_json_es
136136
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
137137
"Content-Language" => "es",
138138
"Content-Type" => "text/plain;charset=utf-8",
139-
"Host" => "gateway.watsonplatform.net"
139+
"Host" => "gateway-wdc.watsonplatform.net"
140140
}
141141
).to_return(status: 200, body: profile_response.to_json, headers: headers)
142142
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")

0 commit comments

Comments
 (0)