apm-agent-java: WebFlux - transaction has status code 200 where it should be 500

  1. spring version 2.2.6 webflux, netty
    @Operation(
        summary = "상품 이미지 검색", description = "상품 이미지 검색 api", responses = {
            @ApiResponse(responseCode = "200", description = "상품 이미지 검색 성공", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class))),
            @ApiResponse(responseCode = "404", description = "상품 이미지 검색 실패", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class)))
        }
    )
    @GetMapping("/goods")
    @ReactorCacheables(cacheNames = CacheNameConstant.GOODS_IMAGE_LIST, key = "getCacheKey(#method)")
    public Mono<ResponseDTOV2> getGoodsList(@ParameterObject @ModelAttribute @Valid GoodsDTOV1.Search goods) {
        return goodsService.getGoodsList(goods.getUrl(), ImageSearchTypeEnum.getValue(goods.getImageSearchType()))
            .flatMap(goodsImageVO -> {

                final GoodsDTOV1.ImageResponse imageResponse = goodsMapStruct.toDTO(goodsImageVO);

                if (1 == 1) {
                    throw new RuntimeException();
                }

                return Mono.just(
                    ResponseDTOV2.builder().data(imageResponse).build()
                );
            });
    }


Obviously a status 500 internal server error occurred.
In elastic-apm it comes out as 200

image

image

    @Operation(
        summary = "상품 이미지 검색", description = "상품 이미지 검색 api", responses = {
            @ApiResponse(responseCode = "200", description = "상품 이미지 검색 성공", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class))),
            @ApiResponse(responseCode = "404", description = "상품 이미지 검색 실패", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class)))
        }
    )
    @GetMapping("/goods")
    @ReactorCacheables(cacheNames = CacheNameConstant.GOODS_IMAGE_LIST, key = "getCacheKey(#method)")
    public Mono<ResponseDTOV2> getGoodsList(@ParameterObject @ModelAttribute @Valid GoodsDTOV1.Search goods) {

         if (1 == 1) {
                throw new RuntimeException();
         }

        return goodsService.getGoodsList(goods.getUrl(), ImageSearchTypeEnum.getValue(goods.getImageSearchType()))
            .flatMap(goodsImageVO -> {

                final GoodsDTOV1.ImageResponse imageResponse = goodsMapStruct.toDTO(goodsImageVO);



                return Mono.just(
                    ResponseDTOV2.builder().data(imageResponse).build()
                );
            });
    }

image

If the exception is outside of mono, it is exposed normally, but if an error occurs inside mono, it does not work properly.

404 is normal image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 30 (12 by maintainers)

Most upvoted comments

Oh nevermind - It looks like 1.26.0 was just released and it seems to resolve the issue I was facing. Thanks!

okay @SylvainJuge i will try soon