These are chat archives for spring-cloud/spring-cloud

25th
Apr 2019
Anton Fedosov
@acidelk
Apr 25 10:51

Hi!
I have a problem with sleuth after migration to sleuth-core 2.0.2 -> 2.1.x.
After migration i does not have a traceId. Mb my problem is related with small custom WebFilter.

    override fun getBody(): Flux<DataBuffer> {

        return DataBufferUtils.join(super.getBody())
            .doOnNext { logRequestBody(it) }
            .toFlux()
    }

    private fun logRequestBody(buffer: DataBuffer) {
        if (loggingProperties.isExtendedLoggingEnabled) {
            log.info(
                Markers.appendEntries(markers),
                "request body=${getBodyString(buffer)}"
            )
        }
    }

    private fun getBodyString(buffer: DataBuffer): String {
        var body = buffer.asString().replace("\u0000", "")
        if (loggingProperties.isPrettied) {
            body = jsonFormatter.toPrettyJsonString(body)
        }
        return body
    }

Has anyone had this?

Brian Devins-Suresh
@devinsba
Apr 25 13:39
@acidelk sleuth has itโ€™s own room: https://gitter.im/spring-cloud/spring-cloud-sleuth
Anton Fedosov
@acidelk
Apr 25 13:39
sorry :)
Emmanuel J. Reyme
@ejreyme
Apr 25 16:08
Hey spring cloud folks. Anyone familiar with setting up a webclient test that makes a request to a service registered to a discovery server?
Marcin Grzejszczak
@marcingrzejszczak
Apr 25 17:37
Mark it as a @bean nd @loadbalanced
Emmanuel J. Reyme
@ejreyme
Apr 25 17:39
Hey @marcingrzejszczak I'm able to setup a project with a discovery server service and two discovery clients services (one resource and client) using @loadbalanced on a @bean webclient.builder. I'm trying to setup a test that valids the interaction between (resource/client)
Emmanuel J. Reyme
@ejreyme
Apr 25 17:51
The specific issue I run into is an unknown host exception. This occurs when I test the service class making the webclient request to another discovery client. I'm looking for a strategy to setup a discovery server mock config for my test.
Marcin Grzejszczak
@marcingrzejszczak
Apr 25 18:00
I don't understand what you're trying to test
Emmanuel J. Reyme
@ejreyme
Apr 25 18:09
A method like this.
public Mono<ResponseEntity> sendToService(Object someObj) {

        return this.webClientBuilder.build()
                .post()
                .uri("http://service")
                .contentType(MediaType.APPLICATION_JSON_UTF8)
                .body(BodyInserters.fromObject(someObj))
                .retrieve().bodyToMono(ResponseEntity.class);
    }
Marcin Grzejszczak
@marcingrzejszczak
Apr 25 18:28
So use spring cloud contract and you won't have to mock anything manually
Emmanuel J. Reyme
@ejreyme
Apr 25 18:42
That makes perfect sense. I'll go with cloud contracts instead.
Thanks! @marcingrzejszczak
Marcin Grzejszczak
@marcingrzejszczak
Apr 25 18:45
๐Ÿ‘
Nasibulloh
@Nasibulloh
Apr 25 19:42
Hi there, I have a question with microservices. I split monolith services into pieces(microservices). When I sent a request from the main application(REST for Mobile) to one of the services, it returned an exception. Status of the exception let's imagine NOT_FOUND, the code is 404, the message is equal to "User not found". I am sending the request via RestTemplate. But RestTemplate returns only 404 (NOT_FOUND). I customized the exception like a class. RestTemplate is not returning my custom error from the service.
image.png