Skip to content

Commit 9c03af0

Browse files
committed
try patching URL building logic
1 parent d42530c commit 9c03af0

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

datadog-crashtracker/src/crash_info/errors_intake.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ impl ErrorsIntakeUploader {
204204
telemetry_endpoint: &Option<Endpoint>,
205205
) -> anyhow::Result<Self> {
206206
let endpoint = Self::build_errors_intake_endpoint(telemetry_endpoint)?;
207+
eprintln!(
208+
"DEBUG: Created errors intake uploader with URL: {}",
209+
endpoint.url
210+
);
207211
Ok(Self { endpoint })
208212
}
209213

@@ -214,12 +218,13 @@ impl ErrorsIntakeUploader {
214218
Some(endpoint) => {
215219
let mut errors_endpoint = endpoint.clone();
216220

217-
// Modify the path based on whether we're using agent proxy or direct intake
218-
let _new_path = if endpoint.api_key.is_some() {
221+
// Modify the endpoint based on whether we're using agent proxy or direct intake
222+
if endpoint.api_key.is_some() {
219223
// Direct intake - change hostname to event-platform-intake
220224
let mut parts = endpoint.url.clone().into_parts();
221225

222226
// Update the authority to use event-platform-intake subdomain
227+
// Only modify authority for production domains, not localhost
223228
if let Some(authority) = parts.authority.as_ref() {
224229
let authority_str = authority.as_str();
225230
let new_authority = if authority_str.contains("datad0g.com") {
@@ -228,6 +233,11 @@ impl ErrorsIntakeUploader {
228233
} else if authority_str.contains("datadoghq.com") {
229234
authority_str
230235
.replace("instrumentation-telemetry-intake", ERROR_INTAKE_SUBDOMAIN)
236+
} else if authority_str.starts_with("localhost")
237+
|| authority_str.starts_with("127.0.0.1")
238+
{
239+
// For localhost, keep the same authority for direct intake testing
240+
authority_str.to_string()
231241
} else {
232242
// For other domains, prepend event-platform-intake
233243
format!("{}.{}", ERROR_INTAKE_SUBDOMAIN, authority_str)
@@ -240,24 +250,23 @@ impl ErrorsIntakeUploader {
240250
);
241251
}
242252

253+
// Set direct intake path
243254
parts.path_and_query = Some(
244255
ERROR_INTAKE_DIRECT_PATH
245256
.parse()
246257
.context("Failed to parse direct errors intake path")?,
247258
);
248259

249260
errors_endpoint.url = Uri::from_parts(parts)?;
250-
ERROR_INTAKE_DIRECT_PATH
251261
} else {
252-
// Agent proxy - use evp_proxy path
262+
// Agent proxy - keep same authority, just change path to evp_proxy
253263
let mut parts = endpoint.url.clone().into_parts();
254264
parts.path_and_query = Some(
255265
ERROR_INTAKE_AGENT_PATH
256266
.parse()
257267
.context("Failed to parse agent errors intake path")?,
258268
);
259269
errors_endpoint.url = Uri::from_parts(parts)?;
260-
ERROR_INTAKE_AGENT_PATH
261270
};
262271

263272
Ok(errors_endpoint)
@@ -283,11 +292,19 @@ impl ErrorsIntakeUploader {
283292
sig_info: &SigInfo,
284293
metadata: &Metadata,
285294
) -> anyhow::Result<()> {
295+
eprintln!(
296+
"DEBUG: Sending crash ping to errors intake URL: {}",
297+
self.endpoint.url
298+
);
286299
let payload = ErrorsIntakePayload::from_crash_ping(crash_uuid, sig_info, metadata)?;
287300
self.send_payload(&payload).await
288301
}
289302

290303
pub async fn upload_to_errors_intake(&self, crash_info: &CrashInfo) -> anyhow::Result<()> {
304+
eprintln!(
305+
"DEBUG: Sending crash report to errors intake URL: {}",
306+
self.endpoint.url
307+
);
291308
let payload = ErrorsIntakePayload::from_crash_info(crash_info)?;
292309
self.send_payload(&payload).await
293310
}

datadog-crashtracker/src/crash_info/telemetry.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{fmt::Write, time::SystemTime};
55
use crate::SigInfo;
66

77
use super::{build_crash_ping_message, CrashInfo, ErrorsIntakeUploader, Metadata};
8-
use anyhow::{Context, Ok};
8+
use anyhow::Context;
99
use chrono::{DateTime, Utc};
1010
use ddcommon::Endpoint;
1111
use ddtelemetry::{
@@ -148,9 +148,13 @@ impl TelemetryCrashUploader {
148148

149149
let host = build_host();
150150

151-
// Try to create errors intake uploader - it's optional and non-blocking
152151
let errors_intake_uploader =
153-
ErrorsIntakeUploader::new(crashtracker_metadata, endpoint).ok(); // Ignore errors for now, errors intake is optional
152+
match ErrorsIntakeUploader::new(crashtracker_metadata, endpoint) {
153+
Ok(uploader) => Some(uploader),
154+
Err(e) => {
155+
panic!("Failed to create errors intake uploader: {e}");
156+
}
157+
};
154158

155159
let s = Self {
156160
metadata: TelemetryMetadata {

0 commit comments

Comments
 (0)