@@ -142,16 +142,10 @@ impl CrashtrackerConfiguration {
142
142
143
143
// If no secondary endpoint is provided but we have a primary endpoint,
144
144
// derive a default secondary endpoint
145
- // let secondary_endpoint = secondary_endpoint.or_else(|| {
146
- // endpoint
147
- // .as_ref()
148
- // .and_then(|primary| derive_default_secondary_endpoint(primary))
149
- // });
150
-
151
145
let secondary_endpoint = secondary_endpoint. or_else ( || {
152
- let derived = derive_default_secondary_endpoint ( endpoint. as_ref ( ) . unwrap ( ) ) ;
153
- panic ! ( "{}" , format! ( "new_with_secondary: {:?}" , derived ) ) ;
154
- endpoint . as_ref ( ) . and_then ( |primary| derived )
146
+ endpoint
147
+ . as_ref ( )
148
+ . and_then ( |primary| derive_default_secondary_endpoint ( primary ) )
155
149
} ) ;
156
150
157
151
// Note: don't check the receiver socket upfront, since a configuration can be interned
@@ -314,9 +308,31 @@ fn derive_default_secondary_endpoint(primary: &Endpoint) -> Option<Endpoint> {
314
308
return None ;
315
309
} ;
316
310
311
+ // For Error Tracking endpoints, we need an API key
312
+ let api_key = primary. api_key . clone ( ) . or_else ( || {
313
+ std:: env:: var ( "DD_API_KEY" )
314
+ . ok ( )
315
+ . map ( std:: borrow:: Cow :: Owned )
316
+ } ) ;
317
+
318
+ let debug_msg = format ! (
319
+ "DEBUG: Creating secondary endpoint: {} with api_key: {}\n " ,
320
+ secondary_url,
321
+ if api_key. is_some( ) {
322
+ "present"
323
+ } else {
324
+ "missing"
325
+ }
326
+ ) ;
327
+ let _ = std:: fs:: OpenOptions :: new ( )
328
+ . create ( true )
329
+ . append ( true )
330
+ . open ( "/tmp/crashtracker_debug.log" )
331
+ . and_then ( |mut f| std:: io:: Write :: write_all ( & mut f, debug_msg. as_bytes ( ) ) ) ;
332
+
317
333
Some ( Endpoint {
318
334
url : secondary_url. parse ( ) . ok ( ) ?,
319
- api_key : primary . api_key . clone ( ) ,
335
+ api_key,
320
336
timeout_ms : primary. timeout_ms ,
321
337
test_token : primary. test_token . clone ( ) ,
322
338
} )
0 commit comments