File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
logstash-core/src/main/java/org/logstash Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,10 @@ private long estimateMemory(Object o) {
271271 return Double .BYTES ;
272272 }
273273
274- throw new RuntimeException ("Unsupported type in estimating memory size of event: " + o .getClass ());
274+ throw new IllegalArgumentException (
275+ "Unsupported type encountered in estimateMemory: " + o .getClass ().getName () +
276+ ". Please ensure all objects passed to estimateMemory are of supported types. " +
277+ "Refer to the ConvertedMap.estimateMemory method for the list of supported types."
278+ );
275279 }
276280}
Original file line number Diff line number Diff line change 11package org .logstash .execution ;
22
3+ import org .apache .logging .log4j .LogManager ;
4+ import org .apache .logging .log4j .Logger ;
35import org .jruby .runtime .ThreadContext ;
46import org .logstash .ackedqueue .QueueFactoryExt ;
57import org .logstash .ext .JrubyEventExtLibrary ;
1113import static org .logstash .instrument .metrics .MetricKeys .*;
1214
1315class QueueReadClientBatchMetrics {
16+
17+ private static final Logger LOG = LogManager .getLogger (QueueReadClientBatchMetrics .class );
18+
1419 private final QueueFactoryExt .BatchMetricMode batchMetricMode ;
1520
1621 private LongCounter pipelineMetricBatchCount ;
@@ -50,8 +55,12 @@ public void updateBatchMetrics(QueueBatch batch) {
5055
5156 private void updateBatchSizeMetric (QueueBatch batch ) {
5257 long totalSize = 0L ;
53- for (JrubyEventExtLibrary .RubyEvent rubyEvent : batch .events ()) {
54- totalSize += rubyEvent .getEvent ().estimateMemory ();
58+ try {
59+ for (JrubyEventExtLibrary .RubyEvent rubyEvent : batch .events ()) {
60+ totalSize += rubyEvent .getEvent ().estimateMemory ();
61+ }
62+ } catch (IllegalArgumentException e ) {
63+ LOG .error ("Failed to calculate batch byte size for metrics" , e );
5564 }
5665 pipelineMetricBatchByteSize .increment (totalSize );
5766 }
You can’t perform that action at this time.
0 commit comments