hypertrace / javaagent

Hypertrace OpenTelemetry Java agent with payload/body and headers data capture.
Apache License 2.0
33 stars 15 forks source link

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

Closed shantanu-vsbhosale closed 3 years ago

shantanu-vsbhosale commented 3 years ago

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

pavolloffay commented 3 years ago

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.

pavolloffay commented 3 years ago

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);
  }
pavolloffay commented 3 years ago

Closing this as cannot reproduce