It’s at all times a good suggestion to test that the design behaves as anticipated. We are able to use OpenTelemetry for this. For extra data on the right way to arrange OpenTelemetry in such an structure, please confer with Finish-to-end tracing with OpenTelemetry.
Notice that Apache ShardingSphere helps OpenTelemetry however doesn’t present the binary agent. You have to construct it from supply. I admit I used to be too lazy to do it.
Let’s begin with a headerless request:
curl localhost:9080/thingies/1
It makes use of the default route outlined in APISIX and returns the right knowledge, due to ShardingSphere. Now, let’s set the nation to fr
, which is appropriate.
curl -H 'X-Nation: fr' localhost:9080/thingies/1
APISIX appropriately forwards the request to the Europe-located app.
Lastly, think about a malicious actor altering the header to get their palms on knowledge which might be positioned within the US.
curl -H 'X-Nation: us' localhost:9080/thingies/1
APISIX forwards it to the USA-located app in keeping with the header. Nonetheless, Shardingsphere nonetheless fetches knowledge from Europe.