Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridge: remove long-living span around metrics collection #1509

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions bridge/svix-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use svix_bridge_types::{PollerInput, SenderInput, TransformerJob};
use svix_ksuid::{KsuidLike as _, KsuidMs};
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
use tikv_jemallocator::Jemalloc;
use tracing::Instrument;
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _};

use self::config::Config;
Expand Down Expand Up @@ -279,33 +278,26 @@ async fn main() -> Result<()> {
let _metrics = setup_metrics(&cfg);
tracing::info!("starting");

tokio::spawn(
async move {
let mut interval = tokio::time::interval(Duration::from_secs(15));
let metrics = CommonMetrics::new(&opentelemetry::global::meter("svix.com"));
match get_allocator_stat_mibs() {
Ok(mibs) => {
tracing::debug!("Common Metrics Collection: Started");

loop {
interval.tick().await;

if let Ok(Some((allocated, resident))) =
get_allocator_stats(true, mibs.clone())
{
metrics.record_mem_allocated(allocated as _);
metrics.record_mem_resident(resident as _);
}
tokio::spawn(async move {
let mut interval = tokio::time::interval(Duration::from_secs(15));
let metrics = CommonMetrics::new(&opentelemetry::global::meter("svix.com"));
match get_allocator_stat_mibs() {
Ok(mibs) => {
tracing::debug!("Common Metrics Collection: Started");

loop {
interval.tick().await;

if let Ok(Some((allocated, resident))) = get_allocator_stats(true, mibs.clone())
{
metrics.record_mem_allocated(allocated as _);
metrics.record_mem_resident(resident as _);
}
}
Err(e) => tracing::error!("Unable to get allocator stats mibs: {e}"),
}
Err(e) => tracing::error!("Unable to get allocator stats mibs: {e}"),
}
.instrument(tracing::error_span!(
"common_metrics_collector",
instance_id = tracing::field::Empty
)),
);
});

let (xform_tx, mut xform_rx) = tokio::sync::mpsc::unbounded_channel::<TransformerJob>();

Expand Down