Tracers whose settings change start over on reload
A cluster rehearsal moved a Log tracer to another directory: the write was reported x:settingsReload applied:true, but the tracer kept writing to the old file until a restart. Telemetry::update only refreshed each running tracer's events, level and lossiness; a tracer's own settings (path, prefix, rotation, format, endpoint, headers, ...) stayed as built. Each tracer now carries a hash of the registry object it was built from, less the fields that change in place. The reload compares it with the running tracer's: unchanged ones are updated in place as before, changed ones are started over, new ones started and removed ones stopped. Only tracers this server started are removed; upstream removed every subscriber not in the settings, which also cut off live-tracing streams on each reload. Starting over is a swap in the collector, so no event is lost or written twice: a subscriber registered under a running one's id replaces it between two collection passes. The old one's batch is sent first (what its full channel can't take moves to the new one), and dropping it closes its channel, so its task writes what is queued and ends. Per tracer kind: - Log: a tracer started over on the same files (rotation or format changed) waits for the old one to finish, so lines don't interleave. - Webhook: the task held a sender of its own channel for retries, so it never ended; retries now use a weak sender, and pending events are posted when the channel closes. - OpenTelemetry: pending logs and spans are exported when the channel closes instead of dropped, and a span that was open across the swap is exported by the new tracer with the events it saw. - Console and journal: nothing kept between batches. - Trace history: built from the tracing store, which takes a restart, so it is never started over. No kind needs a restart, so x:settingsReload doesn't gain one. system::tracer_reload::tracer_reload_tests (new): a Log tracer created over JMAP writes to its directory; its path is changed over JMAP while 2000 numbered events are emitted; after the reload, events land in the new file and not the old one, each numbered event is in exactly one of the two files, and a destroyed tracer writes nothing. On main the new file never appears.
This commit is contained in:
@@ -245,9 +245,27 @@ impl Collector {
|
||||
Update::RegisterReceiver { receiver } => {
|
||||
self.receivers.push(receiver);
|
||||
}
|
||||
Update::RegisterSubscriber { subscriber } => {
|
||||
ACTIVE_SUBSCRIBERS.lock().push(subscriber.id.clone());
|
||||
self.subscribers.push(subscriber);
|
||||
Update::RegisterSubscriber { mut subscriber } => {
|
||||
// inbuxa: a subscriber registered under the id of a
|
||||
// running one replaces it (a tracer whose settings
|
||||
// changed). Every event collected so far went to the old
|
||||
// one, every later event goes to the new one: the old
|
||||
// one's batch is sent first (anything its full channel
|
||||
// can't take moves over, rather than being dropped), and
|
||||
// dropping it closes its channel, so its task writes
|
||||
// what is queued and ends.
|
||||
if let Some(old) = self.subscribers.iter_mut().find(|s| s.id == subscriber.id) {
|
||||
let _ = old.send_batch();
|
||||
if !old.batch.is_empty() {
|
||||
let mut batch = std::mem::take(&mut old.batch);
|
||||
batch.append(&mut subscriber.batch);
|
||||
subscriber.batch = batch;
|
||||
}
|
||||
*old = subscriber;
|
||||
} else {
|
||||
ACTIVE_SUBSCRIBERS.lock().push(subscriber.id.clone());
|
||||
self.subscribers.push(subscriber);
|
||||
}
|
||||
}
|
||||
Update::UnregisterSubscriber { id } => {
|
||||
ACTIVE_SUBSCRIBERS.lock().retain(|s| s != &id);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use std::sync::Arc;
|
||||
@@ -105,6 +107,9 @@ impl SubscriberBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Registers the subscriber with the collector. inbuxa: one registered
|
||||
/// under the id of a running subscriber replaces it, handing over at an
|
||||
/// event boundary; the old one's channel then closes.
|
||||
pub fn register(self) -> (mpsc::Sender<EventBatch>, mpsc::Receiver<EventBatch>) {
|
||||
let (tx, rx) = mpsc::channel(8192);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user