Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(progress_tracing): push otlp requests through a reqwest client

Steven Enamakelda002e66536a
diff --git a/crates/openhuman-core/src/agent/progress_tracing/flow_export_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/flow_export_tests.rs
index dc5000a355..bcec48b5ac 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/flow_export_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/flow_export_tests.rs
@@ -6,6 +6,20 @@ use tinyflows_bus::runs::FlowRunTrigger;
use wiremock::matchers::{body_json, header, method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
+fn attributed_test_client() -> reqwest::Client {
+ let mut headers = reqwest::header::HeaderMap::new();
+ headers.insert(
+ crate::backend::transport::plain::TEST_PRODUCT_HEADER,
+ reqwest::header::HeaderValue::from_static(
+ crate::backend::transport::plain::TEST_PRODUCT_IDENTITY,
+ ),
+ );
+ reqwest::Client::builder()
+ .default_headers(headers)
+ .build()
+ .expect("attributed test client")
+}
+
fn sample_observations(thread_id: &str) -> Vec<GraphObservation> {
let node = NodeId::new("fetch");
let mk = |offset: u64, step: usize, ts_ms: u64, event: GraphEvent| GraphObservation {
@@ -296,15 +310,10 @@ async fn shared_otlp_transport_posts_rendered_graph_json_with_attribution() {
.await;
let url = format!("{}/otel/v1/traces", server.uri());
- let transport = crate::backend::transport::plain::PlainHttpTransport::fresh();
- super::super::otlp::push_otlp_json_requests_via(
- transport.as_ref(),
- &url,
- "session-token",
- &requests,
- )
- .await
- .expect("send graph request through shared authenticated transport");
+ let client = attributed_test_client();
+ super::super::otlp::push_otlp_json_requests_via(&client, &url, "session-token", &requests)
+ .await
+ .expect("send graph request through shared authenticated transport");
}
#[tokio::test]
@@ -327,15 +336,10 @@ async fn shared_otlp_transport_reports_http_and_partial_rejections() {
.mount(&server)
.await;
let url = format!("{}/otel/v1/traces", server.uri());
- let transport = crate::backend::transport::plain::PlainHttpTransport::fresh();
- let error = super::super::otlp::push_otlp_json_requests_via(
- transport.as_ref(),
- &url,
- "token",
- &requests,
- )
- .await
- .expect_err("HTTP failure must be reported");
+ let client = attributed_test_client();
+ let error = super::super::otlp::push_otlp_json_requests_via(&client, &url, "token", &requests)
+ .await
+ .expect_err("HTTP failure must be reported");
assert!(error.contains("503"), "{error}");
let server = MockServer::start().await;
@@ -347,14 +351,9 @@ async fn shared_otlp_transport_reports_http_and_partial_rejections() {
.mount(&server)
.await;
let url = format!("{}/otel/v1/traces", server.uri());
- let transport = crate::backend::transport::plain::PlainHttpTransport::fresh();
- let error = super::super::otlp::push_otlp_json_requests_via(
- transport.as_ref(),
- &url,
- "token",
- &requests,
- )
- .await
- .expect_err("partial rejection must be reported");
+ let client = attributed_test_client();
+ let error = super::super::otlp::push_otlp_json_requests_via(&client, &url, "token", &requests)
+ .await
+ .expect_err("partial rejection must be reported");
assert!(error.contains("partially rejected"), "{error}");
}
diff --git a/crates/openhuman-core/src/agent/progress_tracing/otlp.rs b/crates/openhuman-core/src/agent/progress_tracing/otlp.rs
index bf686e5354..bb7065342f 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/otlp.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/otlp.rs
@@ -22,20 +22,19 @@ pub(super) async fn push_otlp_json_requests(
) -> Result<(), String> {
let transport = crate::backend::resolve_backend_transport()
.map_err(|err| format!("Langfuse OTLP push has no backend transport: {err}"))?;
- push_otlp_json_requests_via(transport.as_ref(), url, token, requests).await
+ let client = transport.http_client(crate::backend::TransportProfile::Api);
+ push_otlp_json_requests_via(&client, url, token, requests).await
}
pub(super) async fn push_otlp_json_requests_via(
- transport: &dyn crate::backend::BackendTransport,
+ client: &reqwest::Client,
url: &str,
token: &str,
requests: &[Value],
) -> Result<(), String> {
- let client = transport.http_client(crate::backend::TransportProfile::Api);
for payload in requests {
let response = client
.post(url)
- .headers(transport.attribution_headers())
.header(
reqwest::header::AUTHORIZATION,
bearer_authorization_value(token),