1

We are using annotation based span tags to tag method values and request object in controller. We have seen two behaviors

  • When there is error or runtime exception trace object gets http status 500 and error message which is expected.
  • When API call is successful it doesn't not show any http status code tag in span object which should be 200 ok.

We are not able to include api response object in span. Controller API call is like this:

  @PostMapping(path = "/{reuqestParam}/submit")
  @ContinueSpan(log = "submit")
  public IngestionResponse submit(final InputStream inputStream,
      @SpanTag("reuqestParam") @PathVariable String reuqestParam,
      @SpanTag("HttpHeaders") @RequestHeader HttpHeaders httpHeaders) {
    LOGGER.info("[Upload to Stream]: Begin");
    final IngestionResponse ingestionResponse = ingestionService
        .ingestInputStream(inputStream, reuqestParam, httpHeaders);
    LOGGER.info("[Upload to Stream]: Completed");
    return ingestionResponse;
  }

Span object contains method parameter / method name but HTTP status code is missing also response object. We need to capture both information regardless api success or failure.

viren
  • 1,073
  • 1
  • 17
  • 41

1 Answers1

1

You will need to create an instance of HttpServerParser overriding this bean: https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java#L109

The reason is documented in the default implementation: https://github.com/apache/incubator-zipkin-brave/blob/master/instrumentation/http/src/main/java/brave/http/HttpParser.java#L75...L94

You should be able to override that with minimal changes