Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception parameter of any metric is ALWAYS "none" #436

Open
gagarin-it opened this issue Aug 18, 2022 · 0 comments
Open

Exception parameter of any metric is ALWAYS "none" #436

gagarin-it opened this issue Aug 18, 2022 · 0 comments

Comments

@gagarin-it
Copy link

gagarin-it commented Aug 18, 2022

Expected Behavior

Get request to /prometheus endpoint:

##HELP http_server_requests_seconds
##TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{exception="ConversionErrorException",method="POST",status="400",uri="root",} 2.0
http_server_requests_seconds_sum{exception="ConversionErrorException",method="POST",status="400",uri="root",} 0.055199125
http_server_requests_seconds_count{exception="ClassCastException",method="POST",status="500",uri="root",} 1.0
http_server_requests_seconds_sum{exception="ClassCastException",method="POST",status="500",uri="root",} 0.266171375
http_server_requests_seconds_count{exception="none",method="GET",status="200",uri="/prometheus",} 6.0
http_server_requests_seconds_sum{exception="none",method="GET",status="200",uri="/prometheus",} 0.15734971
HELP http_server_requests_seconds_max
TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{exception="ConversionErrorException",method="POST",status="400",uri="root",} 0.042567958
http_server_requests_seconds_max{exception="ClassCastException",method="POST",status="500",uri="root",} 0.266171375
http_server_requests_seconds_max{exception="none",method="GET",status="200",uri="/prometheus",} 0.047649292

Actual Behaviour

Get request to /prometheus endpoint:

##HELP http_server_requests_seconds
##TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{exception="none",method="POST",status="400",uri="root",} 2.0
http_server_requests_seconds_sum{exception="none",method="POST",status="400",uri="root",} 0.055199125
http_server_requests_seconds_count{exception="none",method="POST",status="500",uri="root",} 1.0
http_server_requests_seconds_sum{exception="none",method="POST",status="500",uri="root",} 0.266171375
http_server_requests_seconds_count{exception="none",method="GET",status="200",uri="/prometheus",} 6.0
http_server_requests_seconds_sum{exception="none",method="GET",status="200",uri="/prometheus",} 0.15734971
HELP http_server_requests_seconds_max
TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{exception="none",method="POST",status="400",uri="root",} 0.042567958
http_server_requests_seconds_max{exception="none",method="POST",status="500",uri="root",} 0.266171375
http_server_requests_seconds_max{exception="none",method="GET",status="200",uri="/prometheus",} 0.047649292

Steps To Reproduce

  1. Start application

  2. Send a POST request via postman, with body as application/json:
    { "title": "Example", "length": 123 }

  3. Get the response: 500 Internal Server Error, with body:
    { "message": "Internal Server Error", "_links": { "self": { "href": "/", "templated": false } }, "_embedded": { "errors": [ { "message": "Internal Server Error: class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap')" } ] } }
    Printed into the console:
    ERROR i.m.http.server.RouteExecutor - Unexpected error occurred: class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap') java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap') at com.example.service.Service.asString(Service.kt:10) at com.example.controller.Controller.example(Controller.kt:25) at com.example.controller.$Controller$Definition$Exec.dispatch(Unknown Source) at io.micronaut.context.AbstractExecutableMethodsDefinition$DispatchedExecutableMethod.invoke(AbstractExecutableMethodsDefinition.java:378) at io.micronaut.context.DefaultBeanContext$4.invoke(DefaultBeanContext.java:583) at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:303) at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:111) at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:103) at io.micronaut.http.server.RouteExecutor.lambda$executeRoute$14(RouteExecutor.java:659) at reactor.core.publisher.FluxDeferContextual.subscribe(FluxDeferContextual.java:49) at reactor.core.publisher.Flux.subscribe(Flux.java:8469) at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:426) at io.micronaut.reactive.reactor.instrument.ReactorSubscriber.onNext(ReactorSubscriber.java:57) at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:172) at io.micronaut.http.server.netty.RoutingInBoundHandler$4.doOnComplete(RoutingInBoundHandler.java:950) at io.micronaut.core.async.subscriber.CompletionAwareSubscriber.onComplete(CompletionAwareSubscriber.java:79) at io.micronaut.http.server.netty.jackson.JsonContentProcessor$1.doOnComplete(JsonContentProcessor.java:136) at io.micronaut.core.async.subscriber.CompletionAwareSubscriber.onComplete(CompletionAwareSubscriber.java:79) at java.base/java.util.Optional.ifPresent(Optional.java:183) at io.micronaut.core.async.processor.SingleThreadedBufferingProcessor.doOnComplete(SingleThreadedBufferingProcessor.java:48) at io.micronaut.jackson.core.parser.JacksonCoreProcessor.doOnComplete(JacksonCoreProcessor.java:94) at io.micronaut.core.async.subscriber.SingleThreadedBufferingSubscriber.onComplete(SingleThreadedBufferingSubscriber.java:71) at io.micronaut.http.server.netty.jackson.JsonContentProcessor.doOnComplete(JsonContentProcessor.java:161) at io.micronaut.core.async.subscriber.CompletionAwareSubscriber.onComplete(CompletionAwareSubscriber.java:79) at io.micronaut.http.netty.reactive.HandlerPublisher.publishMessage(HandlerPublisher.java:383) at io.micronaut.http.netty.reactive.HandlerPublisher.flushBuffer(HandlerPublisher.java:470) at io.micronaut.http.netty.reactive.HandlerPublisher.publishMessageLater(HandlerPublisher.java:360) at io.micronaut.http.netty.reactive.HandlerPublisher.complete(HandlerPublisher.java:423) at io.micronaut.http.netty.reactive.HandlerPublisher.handlerRemoved(HandlerPublisher.java:418) at io.netty.channel.AbstractChannelHandlerContext.callHandlerRemoved(AbstractChannelHandlerContext.java:946) at io.netty.channel.DefaultChannelPipeline.callHandlerRemoved0(DefaultChannelPipeline.java:637) at io.netty.channel.DefaultChannelPipeline.remove(DefaultChannelPipeline.java:477) at io.netty.channel.DefaultChannelPipeline.remove(DefaultChannelPipeline.java:423) at io.micronaut.http.netty.stream.HttpStreamsHandler.removeHandlerIfActive(HttpStreamsHandler.java:483) at io.micronaut.http.netty.stream.HttpStreamsHandler.handleReadHttpContent(HttpStreamsHandler.java:319) at io.micronaut.http.netty.stream.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:282) at io.micronaut.http.netty.stream.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:134) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93) at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:99) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93) at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:200) at io.netty.handler.flow.FlowControlHandler.read(FlowControlHandler.java:139) at io.netty.channel.AbstractChannelHandlerContext.invokeRead(AbstractChannelHandlerContext.java:686) at io.netty.channel.AbstractChannelHandlerContext.read(AbstractChannelHandlerContext.java:671) at io.micronaut.http.netty.reactive.HandlerPublisher.requestDemand(HandlerPublisher.java:165) at io.micronaut.http.netty.stream.HttpStreamsHandler$2.requestDemand(HttpStreamsHandler.java:273) at io.micronaut.http.netty.reactive.HandlerPublisher$ChannelSubscription.receivedDemand(HandlerPublisher.java:556) at io.micronaut.http.netty.reactive.HandlerPublisher$ChannelSubscription.lambda$request$0(HandlerPublisher.java:494) at io.netty.util.concurrent.AbstractEventExecutor.runTask$$$capture(AbstractEventExecutor.java:174) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:167) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829)

  4. Send a POST request via postman, with body as application/json:
    { "titles": "Example", "length": 123 }

  5. Get the response: 400 Bad Request, with body:
    { "message": "Bad Request", "_links": { "self": { "href": "/", "templated": false } }, "_embedded": { "errors": [ { "message": "Failed to convert argument [body] for value [null] due to: Instantiation of [simple type, class com.example.dto.BodyDto] value failed for JSON property title due to missing (therefore NULL) value for creator parameter title which is a non-nullable type\n at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: com.example.dto.BodyDto[\"title\"])", "path": "/body" } ] } }

Environment Information

Mac OS 12.5 / Windows 11
JDK 11

Example Application

https://github.com/gagarin-it/metrics-not-record-exception

Version

Micronaut: 3.4.4 / 3.6.0 / 3.6.1
Micronaut-Micrometer: 4.2.1 / 4.4.0 / 4.5.0

@gagarin-it gagarin-it changed the title Micrometer registry prometheus not record an exception to metrics Exception parameter of any metric is ALWAYS "none" Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant