: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
use std::sync::Arc;
use common_metrics::{serve, setup_metrics_routes_with_overrides, Matcher};
use tracing::info;
use crate::{
app_context::AppContext,
metric_consts::{
BYTE_HISTOGRAM_BUCKETS, ISSUE_CREATED_EVENT_PROPERTIES_BYTES, S3_FETCHED_BYTES,
S3_PUT_BYTES, SOURCEMAP_EXTERNAL_BYTES, SYMBOL_SET_DECOMPRESSED_BYTES,
SYMBOL_SET_PARSE_INPUT_BYTES,
},
modes::processing::config::ProcessingConfig,
router::get_router,
};
pub async fn start_server(config: ProcessingConfig, context: Arc<AppContext>) -> () {
let router = get_router(context);
let bucket_overrides: &[(Matcher, &[f64])] = &[
(
Matcher::Full(ISSUE_CREATED_EVENT_PROPERTIES_BYTES.into()),
BYTE_HISTOGRAM_BUCKETS,
),
(
Matcher::Full(S3_FETCHED_BYTES.into()),
BYTE_HISTOGRAM_BUCKETS,
),
(Matcher::Full(S3_PUT_BYTES.into()), BYTE_HISTOGRAM_BUCKETS),
(
Matcher::Full(SOURCEMAP_EXTERNAL_BYTES.into()),
BYTE_HISTOGRAM_BUCKETS,
),
(
Matcher::Full(SYMBOL_SET_DECOMPRESSED_BYTES.into()),
BYTE_HISTOGRAM_BUCKETS,
),
(
Matcher::Full(SYMBOL_SET_PARSE_INPUT_BYTES.into()),
BYTE_HISTOGRAM_BUCKETS,
),
];
let router = setup_metrics_routes_with_overrides(router, bucket_overrides);
let bind = format!("{}:{}", config.host, config.port);
info!("Server started and listening on {}", bind);
serve(router, &bind)
.await
.expect("failed to start serving metrics");
}