@@ -107,7 +107,7 @@ async fn main() -> anyhow::Result<()> {
107107 } ;
108108
109109 let dd_host = env:: var ( "DD_AGENT_HOST" ) . unwrap_or_else ( |_| "localhost" . to_string ( ) ) ;
110- let otlp_endpoint = format ! ( "http://{}:{}" , dd_host, config. tracing_otlp_port) ;
110+ let otlp_endpoint = format ! ( "http://{}:{}" , & dd_host, & config. tracing_otlp_port) ;
111111
112112 // from: https://github.com/flashbots/rollup-boost/blob/08ebd3e75a8f4c7ebc12db13b042dee04e132c05/crates/rollup-boost/src/tracing.rs#L127
113113 let filter_name = "tips-ingress-rpc" . to_string ( ) ;
@@ -148,43 +148,48 @@ async fn main() -> anyhow::Result<()> {
148148 trace_cfg. id_generator = Box :: new ( RandomIdGenerator :: default ( ) ) ;
149149
150150 // `with_agent_endpoint` or `with_http_client`?
151- let provider = new_pipeline ( )
152- . with_service_name ( & filter_name)
153- . with_api_version ( ApiVersion :: Version05 )
154- . with_trace_config ( trace_cfg)
155- //.with_http_client(reqwest::Client::new())
156- . with_agent_endpoint ( & otlp_endpoint) // TODO: do we need to configure HTTP client?
157- . install_simple ( ) ?; // TODO: use batch exporter later
158- global:: set_tracer_provider ( provider. clone ( ) ) ;
159- let scope = InstrumentationScope :: builder ( filter_name. clone ( ) )
160- . with_version ( env ! ( "CARGO_PKG_VERSION" ) )
161- . with_schema_url ( semcov:: SCHEMA_URL )
162- . with_attributes ( None )
163- . build ( ) ;
164- let tracer = provider. tracer_with_scope ( scope) ;
165-
166- let trace_filter = Targets :: new ( )
167- . with_default ( LevelFilter :: OFF )
168- . with_target ( & filter_name, LevelFilter :: TRACE ) ;
169-
170- let registry = registry. with ( OpenTelemetryLayer :: new ( tracer) . with_filter ( trace_filter) ) ;
171-
172- tracing:: subscriber:: set_global_default (
173- registry. with (
174- tracing_subscriber:: fmt:: layer ( )
175- . json ( )
176- . with_ansi ( false )
177- . with_writer ( writer)
178- . with_filter ( log_filter. clone ( ) ) ,
179- ) ,
180- ) ?;
151+ let handle = std:: thread:: spawn ( move || {
152+ let provider = new_pipeline ( )
153+ . with_service_name ( & filter_name)
154+ . with_api_version ( ApiVersion :: Version05 )
155+ . with_trace_config ( trace_cfg)
156+ //.with_http_client(reqwest::Client::new())
157+ . with_agent_endpoint ( & otlp_endpoint) // TODO: do we need to configure HTTP client?
158+ . install_simple ( )
159+ . expect ( "Failed to build provider" ) ; // TODO: use batch exporter later
160+ global:: set_tracer_provider ( provider. clone ( ) ) ;
161+ let scope = InstrumentationScope :: builder ( filter_name. clone ( ) )
162+ . with_version ( env ! ( "CARGO_PKG_VERSION" ) )
163+ . with_schema_url ( semcov:: SCHEMA_URL )
164+ . with_attributes ( None )
165+ . build ( ) ;
166+ let tracer = provider. tracer_with_scope ( scope) ;
167+
168+ let trace_filter = Targets :: new ( )
169+ . with_default ( LevelFilter :: OFF )
170+ . with_target ( & filter_name, LevelFilter :: TRACE ) ;
171+
172+ let registry = registry. with ( OpenTelemetryLayer :: new ( tracer) . with_filter ( trace_filter) ) ;
173+
174+ tracing:: subscriber:: set_global_default (
175+ registry. with (
176+ tracing_subscriber:: fmt:: layer ( )
177+ . json ( )
178+ . with_ansi ( false )
179+ . with_writer ( writer)
180+ . with_filter ( log_filter. clone ( ) ) ,
181+ ) ,
182+ )
183+ . expect ( "Failed to set global default" ) ;
184+ } ) ;
185+ handle. join ( ) . expect ( "Failed to join thread" ) ;
181186
182187 info ! (
183188 message = "Starting ingress service" ,
184189 address = %config. address,
185190 port = config. port,
186191 mempool_url = %config. mempool_url,
187- endpoint = %otlp_endpoint
192+ endpoint = %format! ( "http://{}:{}" , & dd_host , & config . tracing_otlp_port )
188193 ) ;
189194
190195 let op_provider: RootProvider < Optimism > = ProviderBuilder :: new ( )
@@ -217,7 +222,7 @@ async fn main() -> anyhow::Result<()> {
217222
218223 handle. stopped ( ) . await ;
219224 // TODO: might need shutdown
220- let _ = provider. shutdown ( ) ;
225+ // let _ = provider.shutdown();
221226 Ok ( ( ) )
222227}
223228
0 commit comments