Skip to content

Commit ffc57f0

Browse files
authored
dogstatsd: reset client state on connection failure (#563)
1 parent b33e7a0 commit ffc57f0

File tree

1 file changed

+7
-4
lines changed
  • metrics-exporter-dogstatsd/src/forwarder

1 file changed

+7
-4
lines changed

metrics-exporter-dogstatsd/src/forwarder/sync.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ impl ClientState {
8585
let old_state = std::mem::replace(self, ClientState::Inconsistent);
8686
match old_state {
8787
ClientState::Inconsistent => unreachable!("transitioned _from_ inconsistent state"),
88-
ClientState::Disconnected(config) => {
89-
let client = Client::from_forwarder_config(&config)?;
90-
*self = ClientState::Ready(config, client);
91-
}
88+
ClientState::Disconnected(config) => match Client::from_forwarder_config(&config) {
89+
Ok(client) => *self = ClientState::Ready(config, client),
90+
Err(e) => {
91+
*self = ClientState::Disconnected(config);
92+
return Err(e);
93+
}
94+
},
9295
ClientState::Ready(config, mut client) => {
9396
let result = client.send(payload);
9497
if result.is_ok() {

0 commit comments

Comments
 (0)