hypertrace/javaagent

Http request body in a trace is truncated to 512 bytes instead of 128 KB

Closed this issue · 3 comments

Use Case
A spring pet clinic app (having POST service) was running which was instrumented by hypertrace java-agent. The app was loaded with multiple POST requests having body ~1MB.
hypertrace traces has the body of a http post request. By default it should capture 128 KB.

Issue
We are only capturing 512 bytes of post request body. See attached images/files.

Solution
The post request body should be 128KB by default.
input_1MB.txt
post_request
output_512B.txt

Correct the default capture size is 128 KB. Which is 128*1024 = 131072 bytes. One string character is 2 bytes. Hence by default 65536 characters should be captured.

EDIT: One string character = 2 bytes applies for UTF-16BE encoding.

I could not reproduce this issue with Jaeger and sample generated spring boot app.

Perhaps the collector or platform is tuncating the result.

Here is the controller method

  @PostMapping("/post/{length}")
  public ResponseEntity<String> post(@PathVariable("length") Integer length, @RequestBody String body) {
    System.out.printf("received: %s", body);

    byte[] arr = new byte[length];
    for (int i = 0; i < length; i++) {
      arr[i] = 'a';
    }

    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
    return new ResponseEntity(new String(arr), headers, HttpStatus.ACCEPTED);
  }

Closing this as cannot reproduce