diff --git a/src/observability/otel.rs b/src/observability/otel.rs index 092fd032c..613232c8a 100644 --- a/src/observability/otel.rs +++ b/src/observability/otel.rs @@ -35,13 +35,15 @@ impl OtelObserver { /// Uses HTTP/protobuf transport (port 4318 by default). /// Falls back to `http://localhost:4318` if no endpoint is provided. pub fn new(endpoint: Option<&str>, service_name: Option<&str>) -> Result { - let endpoint = endpoint.unwrap_or("http://localhost:4318"); + let base_endpoint = endpoint.unwrap_or("http://localhost:4318"); + let traces_endpoint = format!("{}/v1/traces", base_endpoint.trim_end_matches('/')); + let metrics_endpoint = format!("{}/v1/metrics", base_endpoint.trim_end_matches('/')); let service_name = service_name.unwrap_or("zeroclaw"); // ── Trace exporter ────────────────────────────────────── let span_exporter = opentelemetry_otlp::SpanExporter::builder() .with_http() - .with_endpoint(endpoint) + .with_endpoint(&traces_endpoint) .build() .map_err(|e| format!("Failed to create OTLP span exporter: {e}"))?; @@ -59,7 +61,7 @@ impl OtelObserver { // ── Metric exporter ───────────────────────────────────── let metric_exporter = opentelemetry_otlp::MetricExporter::builder() .with_http() - .with_endpoint(endpoint) + .with_endpoint(&metrics_endpoint) .build() .map_err(|e| format!("Failed to create OTLP metric exporter: {e}"))?;