@@ -148,7 +148,7 @@ public void close() {
148
148
try {
149
149
flush ();
150
150
} catch (IOException e ) {
151
- log .log (INFO , "Exception flushing metrics {0} " , e );
151
+ log .log (INFO , "Exception flushing metrics" , e );
152
152
} finally {
153
153
closeSocket ();
154
154
}
@@ -159,26 +159,20 @@ private void closeSocket() {
159
159
try {
160
160
socket .close ();
161
161
} catch (IOException e ) {
162
- log .log (INFO , "Exception trying to close socket {0} " , e );
162
+ log .log (INFO , "Exception trying to close socket" , e );
163
163
}
164
164
socket = null ;
165
165
}
166
166
}
167
167
168
- /**
169
- * 1. Run the pickler script to package all the pending metrics into a single message
170
- * 2. Send the message to graphite
171
- * 3. Clear out the list of metrics
172
- */
173
168
private void writeMetrics () throws IOException {
174
169
if (!metrics .isEmpty ()) {
175
170
try {
176
171
final byte [] payload = pickleMetrics (metrics );
177
172
final byte [] header = ByteBuffer .allocate (4 ).putInt (payload .length ).array ();
178
173
send (header , payload );
179
174
} finally {
180
- // if there was an error, we might miss some data. for now, drop those on the floor and
181
- // try to keep going.
175
+ // if there was an error we might drop some metrics
182
176
metrics .clear ();
183
177
}
184
178
}
@@ -188,7 +182,8 @@ private void send(byte[] header, byte[] payload) throws IOException {
188
182
try {
189
183
sendPayload (header , payload );
190
184
} catch (IOException e ) {
191
- log .log (WARNING , "Retry sending metrics due to {0}" , e );
185
+ // perform a single retry with a new socket connection
186
+ log .log (WARNING , "Retry sending metrics due to " + e );
192
187
closeSocket ();
193
188
this .socket = socketFactory .createSocket (address .getAddress (), address .getPort ());
194
189
sendPayload (header , payload );
0 commit comments