Construct an exporter that pushes to `endpoint` (e.g. `http://collector:4318`). Fails if the underlying `reqwest::Client` cannot be constructed. An empty endpoint is rejected — use [`disabled`](Self::disabled) instead so the intent stays explicit.
(
endpoint: impl Into<String>,
timeout: Duration,
)
| 61 | /// rejected — use [`disabled`](Self::disabled) instead so the |
| 62 | /// intent stays explicit. |
| 63 | pub fn new( |
| 64 | endpoint: impl Into<String>, |
| 65 | timeout: Duration, |
| 66 | ) -> Result<Arc<Self>, TraceExporterError> { |
| 67 | let endpoint = endpoint.into(); |
| 68 | let client = if endpoint.is_empty() { |
| 69 | None |
| 70 | } else { |
| 71 | Some(reqwest::Client::builder().timeout(timeout).build()?) |
| 72 | }; |
| 73 | Ok(Arc::new(Self { |
| 74 | endpoint, |
| 75 | client, |
| 76 | timeout, |
| 77 | })) |
| 78 | } |
| 79 | |
| 80 | /// Build a disabled exporter. `emit` is a no-op. No HTTP client |
| 81 | /// is constructed so this cannot fail. Use in tests and when the |