abhishekrb19 opened a new pull request, #18993:
URL: https://github.com/apache/druid/pull/18993

   Currently, when we use LoggingEmitter and/or LoggingRequestLogger, long, 
complex SQL queries make up the majority of the log volume, so we truncate logs 
to some extent. With these events, this can lead to the "value" part, timestamp 
among other getting truncated since the map's ordering is arbitrary. So this 
patch switches the EventMap to a LinkedHashMap so critical info (e.g., metric 
name and value) are logged first, followed by fields like service dimensions, 
user dimensions and the SQL query itself.
   
   Same idea for the request logger: we log the query context before the SQL 
query itself, which lets us preserve any useful/debuggable information 
deterministically even under truncation.
   
   Given these maps typically have at most ~20–30 key/value pairs, the 
additional overhead of using a LinkedHashMap should be okay.
   
   For example:
   
   ```
   2026-02-06T21:43:41,033 DEBUG 
[qtp1321214620-64[groupBy_[foo1]_379c91c7-40b1-4d40-b86f-340fcde5177b]] 
org.apache.druid.java.util.emitter.core.LoggingEmitter - [metrics] 
{"feed":"metrics","timestamp":"2026-02-06T21:43:41.033Z","metric":"query/bytes","value":138,"service":"druid/historical","host":"localhost:8083","version":"37.0.0-SNAPSHOT","context":{"applyLimitPushDown":true,"defaultTimeout":180000,"engine":"native","finalize":false,"fudgeTimestamp":"1454795020784","groupByOutermost":false,"maxQueuedBytes":5242880,"maxScatterGatherBytes":9223372036854775807,"queryFailTime":1770414400967,"queryId":"379c91c7-40b1-4d40-b86f-340fcde5177b","queryResourceId":"c5f4256c-f84f-40c4-964a-840f1505d9a3","resultAsArray":true,"sliceIndex":23,"sqlOuterLimit":1001,"sqlQueryId":"yay","sqlStringifyArrays":false,"timeout":179998},"dataSource":"foo1","duration":"PT2592000S","hasFilters":"false","id":"379c91c7-40b1-4d40-b86f-340fcde5177b","interval":["2025-09-01T00:00:00.000Z/2025-10-01T00:00:00.000Z"
 
],"numComplexMetrics":"0","numDimensions":"3","numMetrics":"0","remoteAddress":"127.0.0.1","statusCode":200,"success":"true","type":"groupBy"}
   ```
   
   instead of 
   
   ```
   org.apache.druid.java.util.emitter.core.LoggingEmitter - [metrics] 
{"server":"localhost:8083","numComplexMetrics":"0","type":"groupBy","version":"37.0.0-SNAPSHOT","duration":"PT2592000S","feed":"metrics","numDimensions":"3","metric":"query/node/ttfb","hasFilters":"false","service":"druid/broker","host":"localhost:8082","context":{"applyLimitPushDown":true,"defaultTimeout":180000,"engine":"native","finalize":false,"fudgeTimestamp":"1675477114564","groupByOutermost":false,"maxQueuedBytes":5242880,"maxScatterGatherBytes":9223372036854775807,"queryFailTime":1770171694634,"queryId":"51152d78-80c6-452b-ba1f-604c2edde74a","queryResourceId":"b5c87e25-8368-4c1c-b974-8fc6e272e54b","resultAsArray":true,"sliceIndex":23,"sqlOuterLimit":1001,"sqlQueryId":"foo","sqlStringifyArrays":false},"interval":["2025-09-01T00:00:00.000Z/2025-10-01T00:00:00.000Z"],"id":"51152d78-80c6-452b-ba1f-604c2edde74a","numMetrics":"0","value":17,"dataSource":"foo1","timestamp":"2026-02-06T02:18:34.654Z"}
   ```
   
   This PR has:
   
   - [x] been self-reviewed.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [x] been tested in a test Druid cluster.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to