11// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
22// SPDX-License-Identifier: Apache-2.0
33
4- use libdd_common:: Endpoint ;
54use libdd_common_ffi:: slice:: { AsBytes , CharSlice } ;
65use libdd_common_ffi:: { Error , Slice } ;
76pub use libdd_crashtracker:: { OpTypes , StacktraceCollection } ;
@@ -61,7 +60,7 @@ pub struct Config<'a> {
6160 pub demangle_names : bool ,
6261 /// The endpoint to send the crash report to (can be a file://).
6362 /// If None, the crashtracker will infer the agent host from env variables.
64- pub endpoint : Option < & ' a Endpoint > ,
63+ pub endpoint : CharSlice < ' a > ,
6564 /// Optional filename for a unix domain socket if the receiver is used asynchonously
6665 pub optional_unix_socket_filename : CharSlice < ' a > ,
6766 pub resolve_frames : StacktraceCollection ,
@@ -88,29 +87,23 @@ impl<'a> TryFrom<Config<'a>> for libdd_crashtracker::CrashtrackerConfiguration {
8887 }
8988 vec
9089 } ;
91- let create_alt_stack = value. create_alt_stack ;
92- let use_alt_stack = value. use_alt_stack ;
93- let endpoint = value. endpoint . cloned ( ) ;
94- let resolve_frames = value. resolve_frames ;
95- let signals = value. signals . iter ( ) . copied ( ) . collect ( ) ;
96- let timeout = if value. timeout_ms == 0 {
97- None
98- } else {
99- Some ( Duration :: from_millis ( value. timeout_ms as u64 ) )
100- } ;
101- let unix_socket_path = value. optional_unix_socket_filename . try_to_string_option ( ) ?;
102- let demangle_names = value. demangle_names ;
103- Self :: new (
104- additional_files,
105- create_alt_stack,
106- use_alt_stack,
107- endpoint,
108- resolve_frames,
109- signals,
110- timeout,
111- unix_socket_path,
112- demangle_names,
113- )
90+ let mut builder = Self :: builder ( )
91+ . additional_files ( additional_files)
92+ . create_alt_stack ( value. create_alt_stack )
93+ . demangle_names ( value. demangle_names )
94+ . resolve_frames ( value. resolve_frames )
95+ . signals ( value. signals . iter ( ) . copied ( ) . collect ( ) )
96+ . use_alt_stack ( value. use_alt_stack ) ;
97+ if let Some ( url) = value. endpoint . try_to_string_option ( ) ? {
98+ builder = builder. endpoint_url ( & url) ;
99+ }
100+ if value. timeout_ms != 0 {
101+ builder = builder. timeout ( Duration :: from_millis ( value. timeout_ms as u64 ) ) ;
102+ }
103+ if let Some ( path) = value. optional_unix_socket_filename . try_to_string_option ( ) ? {
104+ builder = builder. unix_socket_path ( path) ;
105+ }
106+ builder. build ( )
114107 }
115108}
116109
0 commit comments