Skip to content

Commit a965eab

Browse files
committed
Fix GraphiteSender retry log message
1 parent 3346ea8 commit a965eab

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

metrics-graphite/src/main/java/io/avaje/metrics/graphite/DGraphiteSender.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void close() {
148148
try {
149149
flush();
150150
} catch (IOException e) {
151-
log.log(INFO, "Exception flushing metrics {0}", e);
151+
log.log(INFO, "Exception flushing metrics", e);
152152
} finally {
153153
closeSocket();
154154
}
@@ -159,26 +159,20 @@ private void closeSocket() {
159159
try {
160160
socket.close();
161161
} catch (IOException e) {
162-
log.log(INFO, "Exception trying to close socket {0}", e);
162+
log.log(INFO, "Exception trying to close socket", e);
163163
}
164164
socket = null;
165165
}
166166
}
167167

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-
*/
173168
private void writeMetrics() throws IOException {
174169
if (!metrics.isEmpty()) {
175170
try {
176171
final byte[] payload = pickleMetrics(metrics);
177172
final byte[] header = ByteBuffer.allocate(4).putInt(payload.length).array();
178173
send(header, payload);
179174
} 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
182176
metrics.clear();
183177
}
184178
}
@@ -188,7 +182,8 @@ private void send(byte[] header, byte[] payload) throws IOException {
188182
try {
189183
sendPayload(header, payload);
190184
} 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);
192187
closeSocket();
193188
this.socket = socketFactory.createSocket(address.getAddress(), address.getPort());
194189
sendPayload(header, payload);

0 commit comments

Comments
 (0)