Repository: paritytech/substrate
File: client/network/src/service/out_events.rs (Rust)

Code before:
			metrics.num_channels.with_label_values(&[sender.name]).inc();
		}

		self.event_streams.push(sender);
	}

	/// Sends an event.
	pub fn send(&mut self, event: Event) {
		self.event_streams.retain_mut(|sender| {
			let current_pending = sender.inner.len();
			if current_pending >= sender.queue_size_warning {
				if sender.warning_fired == SenderWarningState::NotFired {
					error!(
						"The number of unprocessed events in channel `{}` exceeded {}.\n\
						 The channel was created at:\n{:}\n
						 The last event was sent from:\n{:}",
						sender.name,
						sender.queue_size_warning,
						sender.creation_backtrace,
						Backtrace::force_capture(),
					);
				} else if sender.warning_fired == SenderWarningState::FiredFree {
					// We don't want to spam the logs, so we only log on debug level
					debug!(
						target: LOG_TARGET,
						"Channel `{}` is overflowed. Number of events: {}",
						sender.name, current_pending
					);
				}
				sender.warning_fired = SenderWarningState::FiredFull;
			} else if sender.warning_fired == SenderWarningState::FiredFull &&
				current_pending < sender.queue_size_warning.wrapping_div(2)
			{
				sender.warning_fired = SenderWarningState::FiredFree;
				debug!(
					target: LOG_TARGET,
					"Channel `{}` is no longer overflowed. Number of events: {}",
					sender.name, current_pending
				);
			}

			sender.inner.try_send(event.clone()).is_ok()
		});

		if let Some(metrics) = &self.metrics {
			for ev in &self.event_streams {
				metrics.event_in(&event, ev.name);
			}
		}
	}
}

Review comment (bug):
```suggestion
						"Channel `{}` is overflowed again. Number of events: {}",
```

Code after:
			metrics.num_channels.with_label_values(&[sender.name]).inc();
		}

		self.event_streams.push(sender);
	}

	/// Sends an event.
	pub fn send(&mut self, event: Event) {
		self.event_streams.retain_mut(|sender| {
			let current_pending = sender.inner.len();
			if current_pending >= sender.queue_size_warning {
				if sender.warning_fired == SenderWarningState::NotFired {
					error!(
						"The number of unprocessed events in channel `{}` exceeded {}.\n\
						 The channel was created at:\n{:}\n
						 The last event was sent from:\n{:}",
						sender.name,
						sender.queue_size_warning,
						sender.creation_backtrace,
						Backtrace::force_capture(),
					);
				} else if sender.warning_fired == SenderWarningState::FiredFree {
					// We don't want to spam the logs, so we only log on debug level
					debug!(
						target: LOG_TARGET,
						"Channel `{}` is overflowed again. Number of events: {}",
						sender.name, current_pending
					);
				}
				sender.warning_fired = SenderWarningState::FiredFull;
			} else if sender.warning_fired == SenderWarningState::FiredFull &&
				current_pending < sender.queue_size_warning.wrapping_div(2)
			{
				sender.warning_fired = SenderWarningState::FiredFree;
				debug!(
					target: LOG_TARGET,
					"Channel `{}` is no longer overflowed. Number of events: {}",
					sender.name, current_pending
				);
			}

			sender.inner.try_send(event.clone()).is_ok()
		});

		if let Some(metrics) = &self.metrics {
			for ev in &self.event_streams {
				metrics.event_in(&event, ev.name);
			}
		}
	}
}