@@ -203,7 +203,6 @@ impl Runtime {
203203 // Build telemetry options
204204 let mut log_forwarder = None ;
205205 let telemetry_options = if let Some ( v) = unsafe { options. telemetry . as_ref ( ) } {
206- // Prepare values
207206 let ( attach_service_name, metric_prefix) =
208207 if let Some ( v) = unsafe { v. metrics . as_ref ( ) } {
209208 ( v. attach_service_name , v. metric_prefix . to_option_string ( ) )
@@ -229,7 +228,6 @@ impl Runtime {
229228 }
230229 } ) ;
231230
232- // Build with all values
233231 CoreTelemetryOptions :: builder ( )
234232 . attach_service_name ( attach_service_name)
235233 . maybe_metric_prefix ( metric_prefix)
@@ -239,17 +237,15 @@ impl Runtime {
239237 CoreTelemetryOptions :: default ( )
240238 } ;
241239
242- let heartbeat_interval = if options. worker_heartbeat_interval_millis == 0 {
243- None
244- } else {
245- Some ( Duration :: from_millis (
246- options. worker_heartbeat_interval_millis ,
247- ) )
248- } ;
249-
250240 let core_runtime_options = CoreRuntimeOptions :: builder ( )
251241 . telemetry_options ( telemetry_options)
252- . maybe_heartbeat_interval ( heartbeat_interval)
242+ . maybe_heartbeat_interval ( if options. worker_heartbeat_interval_millis == 0 {
243+ None
244+ } else {
245+ Some ( Duration :: from_millis (
246+ options. worker_heartbeat_interval_millis ,
247+ ) )
248+ } )
253249 . build ( )
254250 . map_err ( |e| anyhow:: anyhow!( e) ) ?;
255251
@@ -392,29 +388,30 @@ fn create_meter(
392388 ) ) ;
393389 }
394390 // Build OTel exporter
395- let metric_periodicity = if otel_options. metric_periodicity_millis > 0 {
396- Some ( Duration :: from_millis (
397- otel_options. metric_periodicity_millis . into ( ) ,
398- ) )
399- } else {
400- None
401- } ;
402- let build = OtelCollectorOptions :: builder ( )
403- . url ( Url :: parse ( otel_options. url . to_str ( ) ) ?)
404- . headers ( otel_options. headers . to_string_map_on_newlines ( ) )
405- . metric_temporality ( match otel_options. metric_temporality {
406- OpenTelemetryMetricTemporality :: Cumulative => MetricTemporality :: Cumulative ,
407- OpenTelemetryMetricTemporality :: Delta => MetricTemporality :: Delta ,
408- } )
409- . global_tags ( options. global_tags . to_string_map_on_newlines ( ) )
410- . use_seconds_for_durations ( otel_options. durations_as_seconds )
411- . histogram_bucket_overrides ( HistogramBucketOverrides {
412- overrides : parse_histogram_bucket_overrides (
413- & otel_options. histogram_bucket_overrides ,
414- ) ?,
415- } )
416- . maybe_metric_periodicity ( metric_periodicity) ;
417- Ok ( Arc :: new ( build_otlp_metric_exporter ( build. build ( ) ) ?) )
391+ Ok ( Arc :: new ( build_otlp_metric_exporter (
392+ OtelCollectorOptions :: builder ( )
393+ . url ( Url :: parse ( otel_options. url . to_str ( ) ) ?)
394+ . headers ( otel_options. headers . to_string_map_on_newlines ( ) )
395+ . metric_temporality ( match otel_options. metric_temporality {
396+ OpenTelemetryMetricTemporality :: Cumulative => MetricTemporality :: Cumulative ,
397+ OpenTelemetryMetricTemporality :: Delta => MetricTemporality :: Delta ,
398+ } )
399+ . global_tags ( options. global_tags . to_string_map_on_newlines ( ) )
400+ . use_seconds_for_durations ( otel_options. durations_as_seconds )
401+ . histogram_bucket_overrides ( HistogramBucketOverrides {
402+ overrides : parse_histogram_bucket_overrides (
403+ & otel_options. histogram_bucket_overrides ,
404+ ) ?,
405+ } )
406+ . maybe_metric_periodicity ( if otel_options. metric_periodicity_millis > 0 {
407+ Some ( Duration :: from_millis (
408+ otel_options. metric_periodicity_millis . into ( ) ,
409+ ) )
410+ } else {
411+ None
412+ } )
413+ . build ( ) ,
414+ ) ?) )
418415 } else if let Some ( prom_options) = unsafe { options. prometheus . as_ref ( ) } {
419416 if custom_meter. is_some ( ) {
420417 return Err ( anyhow:: anyhow!(
0 commit comments