Skip to content

Update java exception rules to support reactor/webflux formatted exception #87

@sethrylan

Description

@sethrylan

Steps to reproduce

  1. Configure fluent-plugin-detect-exceptions
    <match raw.kubernetes.**>
      @id exceptions
      @type detect_exceptions
      remove_tag_prefix raw
      message message
      stream stream
      multiline_flush_interval 5
      max_bytes 500000
      max_lines 1000
    </match>
  1. Create an exception on a reactive thread. These exceptions follow the format
org.springframework.web.reactive.function.client.WebClientRequestException: finishConnect(..) failed: Connection refused: localhost:8080; nested exception is io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost:8080
	at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
	|_ checkpoint ⇢ Request to GET localhost:8080
Stack trace:
		at org.springframework.web.reactive.function.client.ExchangeFunctions$DefaultExchangeFunction.lambda$wrapException$9(ExchangeFunctions.java:141)
		at reactor.core.publisher.MonoErrorSupplied.subscribe(MonoErrorSupplied.java:70)
		at reactor.core.publisher.Mono.subscribe(Mono.java:4150)
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
		at org.springframework.cloud.sleuth.instrument.reactor.ScopePassingSpanSubscriber.onError(ScopePassingSpanSubscriber.java:95)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221)
		at java.lang.Thread.run(Thread.java:834)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost:8080
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
	at io.netty.channel.unix.Errors.newConnectException0(Errors.java:155)
	at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128)
	at io.netty.channel.unix.Socket.finishConnect(Socket.java:278)
	at java.lang.Thread.run(Thread.java:834)

Results seen

The exception is logged on multiple lines. E.g.,

{ "message": "[2021-09-02 12:57:32:721] [sba-service_v1,,,] [\u001b[33mWARN \u001b[m] - [     parallel-1] d.c.b.a.s.s.InfoUpdater        - Couldn't retrieve info for Instance(id=4189dc1b3bbe, version=3, ....))\n",...}
{ "message": "java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 10000ms in 'map' (and no fallback has been configured)\n\tat reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:295) ~[reactor-core-3.4.8.jar:3.4.8]\n\tSuppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: \n",...}
{ "message": "\t|_ checkpoint ⇢ Request to GET info [DefaultWebClient]\n",...}
{ "message": "Stack trace:\n",...}

(the above example is truncated and formatted for readability)

Results expected

The exception should be combined into a single message.

Related defects

The example above also has the first line of logger output (e.g., [2021-09-02 12:57:32:721] [sba-service_v1,,,] ...) separate, which is caused by #73 and #79

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions