@@ -99,50 +99,71 @@ public void wakeup() {
99
99
}
100
100
101
101
private List <AtlasKafkaMessage <T >> receive (long timeoutMilliSeconds , Map <TopicPartition , Long > lastCommittedPartitionOffset ) {
102
- List <AtlasKafkaMessage <T >> messages = new ArrayList ();
102
+ long methodStart = System .currentTimeMillis ();
103
+ long stepStart = methodStart ; // For individual steps timing
103
104
105
+ List <AtlasKafkaMessage <T >> messages = new ArrayList <>();
106
+ LOG .info ("receive() => Start of method at {} ms" , methodStart );
107
+
108
+ // Poll for records
104
109
ConsumerRecords <?, ?> records = kafkaConsumer != null ? kafkaConsumer .poll (timeoutMilliSeconds ) : null ;
110
+ LOG .info ("receive() [After kafkaConsumer.poll] completed in {} ms" , (System .currentTimeMillis () - stepStart ));
111
+ stepStart = System .currentTimeMillis ();
105
112
106
113
if (records != null ) {
107
- LOG .info ("ObjectPropagate -> Found kafkaRecords : {}" , records .count ());
114
+ LOG .info ("receive() => Found kafkaRecords: {} in {} ms" , records .count (), (System .currentTimeMillis () - stepStart ));
115
+ stepStart = System .currentTimeMillis ();
116
+
108
117
for (ConsumerRecord <?, ?> record : records ) {
109
- // if ( LOG.isDebugEnabled()) {
110
- LOG . info ( "ObjectPropagate -> Received Message topic ={}, partition ={}, offset = {}, key = {}, value = {}" ,
111
- record . topic (), record . partition (), record . offset (), record . key (), record . value ( ));
112
- // }
118
+ LOG .info ( "receive() => Received Message topic={}, partition={}, offset={}, key={}, value={} in {} ms" ,
119
+ record . topic (), record . partition (), record . offset (), record . key (), record . value () ,
120
+ ( System . currentTimeMillis () - stepStart ));
121
+ stepStart = System . currentTimeMillis ();
113
122
114
123
TopicPartition topicPartition = new TopicPartition (record .topic (), record .partition ());
115
124
if (MapUtils .isNotEmpty (lastCommittedPartitionOffset )
116
125
&& lastCommittedPartitionOffset .containsKey (topicPartition )
117
126
&& record .offset () < lastCommittedPartitionOffset .get (topicPartition )) {
118
127
119
128
commit (topicPartition , record .offset ());
120
- LOG .info ("ObjectPropagate -> Skipping already processed message: topic={}, partition={} offset={}. Last processed offset={}" ,
121
- record .topic (), record .partition (), record .offset (), lastCommittedPartitionOffset .get (topicPartition ));
129
+ LOG .info ("receive() => Skipping already processed message: topic={}, partition={}, offset={}. Last processed offset={} in {} ms" ,
130
+ record .topic (), record .partition (), record .offset (), lastCommittedPartitionOffset .get (topicPartition ),
131
+ (System .currentTimeMillis () - stepStart ));
132
+ stepStart = System .currentTimeMillis ();
122
133
continue ;
123
134
}
124
135
125
136
T message = null ;
126
-
127
137
try {
128
- LOG .info ("ObjectPropagate -> Message converting to kafkaMessage" );
138
+ LOG .info ("receive() => Converting message to kafkaMessage in {} ms" , (System .currentTimeMillis () - stepStart ));
139
+ stepStart = System .currentTimeMillis ();
140
+
129
141
message = deserializer .deserialize (record .value ().toString ());
130
- LOG .info ("ObjectPropagate -> Message converted to kafkaMessage : {}" , message .toString ());
142
+ LOG .info ("receive() => Message converted to kafkaMessage: {} in {} ms" ,
143
+ message .toString (), (System .currentTimeMillis () - stepStart ));
144
+ stepStart = System .currentTimeMillis ();
131
145
} catch (OutOfMemoryError excp ) {
132
- LOG .error ("Ignoring message that failed to deserialize: topic={}, partition={}, offset={}, key={}, value={}" ,
133
- record .topic (), record .partition (), record .offset (), record .key (), record .value (), excp );
146
+ LOG .error ("receive() => Ignoring message that failed to deserialize: topic={}, partition={}, offset={}, key={}, value={} in {} ms" ,
147
+ record .topic (), record .partition (), record .offset (), record .key (), record .value (),
148
+ (System .currentTimeMillis () - stepStart ), excp );
134
149
}
135
150
136
151
if (message == null ) {
137
152
continue ;
138
153
}
139
- LOG .info ("ObjectPropagate -> Message added to kafkaMessage batch" );
154
+ LOG .info ("receive() => Adding message to batch in {} ms" , (System .currentTimeMillis () - stepStart ));
155
+ stepStart = System .currentTimeMillis ();
156
+
140
157
messages .add (new AtlasKafkaMessage (message , record .offset (), record .topic (), record .partition (),
141
- deserializer .getMsgCreated (), deserializer .getSpooled ()));
158
+ deserializer .getMsgCreated (), deserializer .getSpooled ()));
159
+ LOG .info ("receive() => Batch size now: {} after {} ms" , messages .size (), (System .currentTimeMillis () - stepStart ));
160
+ stepStart = System .currentTimeMillis ();
142
161
}
143
162
}
144
163
164
+ long totalTime = System .currentTimeMillis () - methodStart ;
165
+ LOG .info ("receive() => End of method, total execution time: {} ms" , totalTime );
145
166
return messages ;
146
-
147
167
}
168
+
148
169
}
0 commit comments