Clone into $GOPATH
and run:
git clone https://gist.github.com/fb3eb8e804cfbf9e1b7d.git repro
cd repro
go build
./repro
{ | |
"$schema": "http://json-schema.org/draft-04/heroku-hyper-schema#", | |
"id": "http://json-schema.org/draft-04/heroku-hyper-schema#", | |
"title": "Heroku JSON Hyper-Schema", | |
"allOf": [ | |
{ | |
"$ref": "http://json-schema.org/draft-04/hyper-schema#" | |
} | |
], | |
"definitions": { |
$ prmd verify docs/v3/schema.json
docs/v3/schema.json: Missing `#/id`
docs/v3/schema.json: Missing `schemata/build-result#/definitions/identity`
docs/v3/schema.json: Missing `schemata/config-var#/properties`
docs/v3/schema.json: Missing `schemata/config-var#/definitions/identity`
But why gen a new id if someone passes you an id? Just use the supplied id in the called srvc.
This is certainly disputable territory, but the main motivation is that depending on service architecture, a single incoming request can balloon out into a full tree of backend requests because requests can map 1:N between any two components. Assigning every request in every component a unique ID allows any particular request to be isolated, while still allowing the any subsection of the tree to be viewed all at once.
Visually, this might look something like this:
Component 1 Component 2 Component 3
+----------------------+----------------------+----------------------+
diff --git a/lib/api/middleware/request_id.rb b/lib/api/middleware/request_id.rb | |
index 9367bf7..255f4e4 100644 | |
--- a/lib/api/middleware/request_id.rb | |
+++ b/lib/api/middleware/request_id.rb | |
@@ -8,7 +8,8 @@ def initialize(app) | |
end | |
def call(env) | |
- request_ids = [SecureRandom.uuid] + extract_request_ids(env) | |
+ extracted_request_ids = extract_request_ids(env) |
I hereby claim:
To claim this, I am signing this object:
> u = User.first | |
=> #<User id: 23, email: "brandur+t003@heroku.com", created_at: "2012-03-13 14:38:11", invited_by_id: nil, last_ | |
login: "2012-03-13 14:39:46", reset_password_hash: nil, salt: nil, password_hash: nil, heroku_garden: nil, last_ | |
git: nil, deleted_at: nil, payment_session_key: nil, confirmed_billing_info: nil, beta: nil, zendesk_created_at: | |
nil, verified_at: nil, billing_name: nil, billing_address: nil, billing_card: nil, invited_on: "2012-03-13 14:3 | |
8:07", invite_converted_on: nil, pending_payment_session_key: nil, cached_usage_total: nil, confirmed_billing_at | |
: nil, max_apps: nil, api_key: "ca0ff390071bf08e038752154dd2c05533a810a9", signup_source_id: 6, rate_limit: nil, | |
first_name: nil, last_name: nil, invitation_secret: nil, password_hash_v2: "$2a$10$5PKpvQaDF2Lp0iGFl9KxKuoLO76s | |
4lMTFdizjxpgGqY4...", pref_site_version: nil, full_name: nil, accepted_tos_at: "2012-03-13 14:38:11", receive_ne | |
wsletter: false, suspended_at: nil, suspicious_since: nil> |
$.ajaxSetup | |
headers: | |
Authorization: "Basic #{toBase64(":supersecretpassword")}" |
%h1 No |
# ab -n 1000 -c 10 -A :xxx https://api.brandur.herokudev.com/apps | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking api.brandur.herokudev.com (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests |