Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(metrics): count metric records capture produces to kafka (#116435)

Daniel Visca34ac77f16fce
diff --git a/rust/capture-logs/src/endpoints/prometheus.rs b/rust/capture-logs/src/endpoints/prometheus.rs
index 83a066576af3..dc2bb73ff180 100644
--- a/rust/capture-logs/src/endpoints/prometheus.rs
+++ b/rust/capture-logs/src/endpoints/prometheus.rs
@@ -502,6 +502,8 @@ pub async fn export_prometheus_remote_write_http(
));
}
+ counter!("capture_metrics_records_produced", "source" => "remote_write")
+ .increment(row_count as u64);
debug!("Sent {row_count} remote-write data points to Kafka");
Ok(StatusCode::NO_CONTENT)
}
diff --git a/rust/capture-logs/src/service.rs b/rust/capture-logs/src/service.rs
index 4b079ea5825b..cbd3a0379bc0 100644
--- a/rust/capture-logs/src/service.rs
+++ b/rust/capture-logs/src/service.rs
@@ -21,6 +21,7 @@ use std::fs::File;
use std::io::Write;
use crate::kafka::KafkaSink;
+use metrics::counter;
use tracing::{debug, error, instrument};
@@ -807,6 +808,8 @@ pub async fn export_metrics_http(
Json(json!({"error": "Internal server error"})),
));
} else {
+ counter!("capture_metrics_records_produced", "source" => "otlp")
+ .increment(row_count as u64);
debug!(
"Successfully sent {} metric data points to Kafka",
row_count