Update Python and Java code snippet (#7330)

Netlify flake
This commit is contained in:
Shamsher Ansari 2020-05-15 23:27:01 +05:30 committed by GitHub
parent fddb179a56
commit 879132e36e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 12 deletions

View File

@ -57,7 +57,7 @@ def getForwardHeaders(request):
# ... # ...
incoming_headers = ['x-request-id'] incoming_headers = ['x-request-id', 'x-datadog-trace-id', 'x-datadog-parent-id', 'x-datadog-sampled']
# ... # ...
@ -69,23 +69,17 @@ def getForwardHeaders(request):
return headers return headers
{{< /text >}} {{< /text >}}
The reviews application (Java) does something similar: The reviews application (Java) does something similar using `requestHeaders`:
{{< text java >}} {{< text java >}}
@GET @GET
@Path("/reviews/{productId}") @Path("/reviews/{productId}")
public Response bookReviewsById(@PathParam("productId") int productId, public Response bookReviewsById(@PathParam("productId") int productId, @Context HttpHeaders requestHeaders) {
@HeaderParam("end-user") String user,
@HeaderParam("x-request-id") String xreq, // ...
@HeaderParam("x-b3-traceid") String xtraceid,
@HeaderParam("x-b3-spanid") String xspanid,
@HeaderParam("x-b3-parentspanid") String xparentspanid,
@HeaderParam("x-b3-sampled") String xsampled,
@HeaderParam("x-b3-flags") String xflags,
@HeaderParam("x-ot-span-context") String xotspan) {
if (ratings_enabled) { if (ratings_enabled) {
JsonObject ratingsResponse = getRatings(Integer.toString(productId), user, xreq, xtraceid, xspanid, xparentspanid, xsampled, xflags, xotspan); JsonObject ratingsResponse = getRatings(Integer.toString(productId), requestHeaders);
{{< /text >}} {{< /text >}}
When you make downstream calls in your applications, make sure to include these headers. When you make downstream calls in your applications, make sure to include these headers.