Menu

1 / 2

Why Quarkus MDC numeric fields silently break OpenSearch queries — and how to fix it

DEV Community·Zahan Turel·6 months ago
#zONHh7gH
#fix#java#quarkus#field#string
Reading 0:00
15s threshold

If you're running Quarkus with JSON logging and shipping to OpenSearch,

there's a non-obvious bug waiting for you: every numeric field you put

in MDC arrives in OpenSearch as a string.

This means queries like durationMs > 1000 silently return nothing.

No error. No warning. Just wrong results.

Here's why it happens and two ways to fix it.

The problem

Quarkus uses JBoss Log Manager under the hood. When you set MDC values:

MDC . put ( "durationMs" , String . valueOf ( duration )); MDC . put ( "fundsProcessed" , String . valueOf ( count ));

Enter fullscreen mode

Exit fullscreen mode

The SLF4J MDC API only accepts String .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.