The AGPL asks a modified version to carry prominent notices saying it was modified, and giving a date. Publishing the source is the conveyance that asks for it, so it wants doing before the repository is public rather than at the release. Every upstream file the fork changed now says so in its header, beneath the notice it came with: 164 files, found by diffing against the upstream snapshot branch rather than by guessing, so the list is what actually differs. Files the fork wrote itself already carry their own copyright and need nothing. Upstream's notices are untouched, which its licence requires and which was already true. The README says the same thing in prose, since the obligation is on the work as a whole and not only its Rust files. Builds unchanged: the server and the test binary both compile.
119 lines
4.0 KiB
Rust
119 lines
4.0 KiB
Rust
/*
|
|
* 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.
|
|
*/
|
|
|
|
pub mod alerts; // inbuxa: monitoring (MON-25 to MON-30)
|
|
pub mod metrics;
|
|
pub mod tracers;
|
|
pub mod webhooks;
|
|
|
|
use tracers::log::spawn_log_tracer;
|
|
use tracers::otel::spawn_otel_tracer;
|
|
use tracers::stdout::spawn_console_tracer;
|
|
use trc::{Collector, ipc::subscriber::SubscriberBuilder};
|
|
use webhooks::spawn_webhook_tracer;
|
|
|
|
use crate::config::telemetry::{Telemetry, TelemetrySubscriberType};
|
|
|
|
impl Telemetry {
|
|
pub fn enable(self) {
|
|
// Spawn tracers
|
|
for tracer in self.tracers.subscribers {
|
|
tracer.typ.spawn(
|
|
SubscriberBuilder::new(tracer.id)
|
|
.with_interests(tracer.interests)
|
|
.with_lossy(tracer.lossy),
|
|
);
|
|
}
|
|
|
|
// Update global collector
|
|
Collector::set_interests(self.tracers.interests);
|
|
Collector::update_custom_levels(self.tracers.levels);
|
|
Collector::set_metrics(self.metrics);
|
|
Collector::reload();
|
|
}
|
|
|
|
pub fn update(self) {
|
|
// Remove tracers that are no longer active
|
|
let active_subscribers = Collector::get_subscribers();
|
|
for subscribed_id in &active_subscribers {
|
|
if !self
|
|
.tracers
|
|
.subscribers
|
|
.iter()
|
|
.any(|tracer| tracer.id == *subscribed_id)
|
|
{
|
|
Collector::remove_subscriber(subscribed_id.clone());
|
|
}
|
|
}
|
|
|
|
// Activate new tracers or update existing ones
|
|
for tracer in self.tracers.subscribers {
|
|
if active_subscribers.contains(&tracer.id) {
|
|
Collector::update_subscriber(tracer.id, tracer.interests, tracer.lossy);
|
|
} else {
|
|
tracer.typ.spawn(
|
|
SubscriberBuilder::new(tracer.id)
|
|
.with_interests(tracer.interests)
|
|
.with_lossy(tracer.lossy),
|
|
);
|
|
}
|
|
}
|
|
|
|
// Update global collector
|
|
Collector::set_interests(self.tracers.interests);
|
|
Collector::update_custom_levels(self.tracers.levels);
|
|
Collector::set_metrics(self.metrics);
|
|
Collector::reload();
|
|
}
|
|
|
|
#[cfg(feature = "test_mode")]
|
|
pub fn test_tracer(level: trc::Level) {
|
|
let mut interests = trc::ipc::subscriber::Interests::default();
|
|
for event in trc::EventType::variants() {
|
|
if level.is_contained(event.level()) {
|
|
interests.set(*event);
|
|
}
|
|
}
|
|
|
|
spawn_console_tracer(
|
|
SubscriberBuilder::new("stderr".to_string())
|
|
.with_interests(interests.clone())
|
|
.with_lossy(false),
|
|
crate::config::telemetry::ConsoleTracer {
|
|
ansi: true,
|
|
multiline: false,
|
|
buffered: false,
|
|
},
|
|
);
|
|
|
|
Collector::union_interests(interests);
|
|
Collector::reload();
|
|
}
|
|
}
|
|
|
|
impl TelemetrySubscriberType {
|
|
pub fn spawn(self, builder: SubscriberBuilder) {
|
|
match self {
|
|
TelemetrySubscriberType::ConsoleTracer(settings) => {
|
|
spawn_console_tracer(builder, settings)
|
|
}
|
|
TelemetrySubscriberType::LogTracer(settings) => spawn_log_tracer(builder, settings),
|
|
TelemetrySubscriberType::Webhook(settings) => spawn_webhook_tracer(builder, settings),
|
|
TelemetrySubscriberType::OtelTracer(settings) => spawn_otel_tracer(builder, settings),
|
|
// inbuxa: MON-10: trace history
|
|
TelemetrySubscriberType::StoreTracer(settings) => {
|
|
tracers::store::spawn_store_tracer(builder, settings.tracing, settings.data)
|
|
}
|
|
#[cfg(unix)]
|
|
TelemetrySubscriberType::JournalTracer(subscriber) => {
|
|
tracers::journald::spawn_journald_tracer(builder, subscriber)
|
|
}
|
|
}
|
|
}
|
|
}
|