fn build_config_and_process(
    config: Option<sdk::trace::Config>,
    service_name_opt: Option<String>,
) -> (sdk::trace::Config, Process) {
    let config = config.unwrap_or_default();

    let service_name = service_name_opt.unwrap_or_else(|| {
        config
            .resource
            .get(semcov::resource::SERVICE_NAME)
            .map(|v| v.to_string())
            .unwrap_or_else(|| "unknown_service".to_string())
    });

    // merge the tags and resource. Resources take priority.
    let mut tags = config
        .resource
        .iter()
        .filter(|(key, _)| **key != semcov::resource::SERVICE_NAME)
        .map(|(key, value)| KeyValue::new(key.clone(), value.clone()))
        .collect::<Vec<KeyValue>>();

    tags.push(KeyValue::new(
        semcov::resource::SERVICE_NAME,
        service_name.clone(),
    ));

    (config, Process { service_name, tags })
}
// To reduce the overhead of copying service name in every spans. We convert resource into jaeger tags
// and store them into process. And set the resource in trace config to empty.
//
// There are multiple ways to set the service name. A `service.name` tag will be always added
// to the process tags.
To reduce the overhead of copying service name in every spans. We convert resource into jaeger tags
and store them into process. And set the resource in trace config to empty.

There are multiple ways to set the service name. A `service.name` tag will be always added
to the process tags.
To reduce the overhead of copying service name in every spans . We convert resource into jaeger tags and store them into process . And set the resource in trace config to empty . There are multiple ways to set the service name . A ` service . name ` tag will be always added to the process tags .
fn build_config_and_process(
    config: Option<sdk::trace::Config>,
    service_name_opt: Option<String>,
) -> (sdk::trace::Config, Process) {
    let config = config.unwrap_or_default();
    let service_name = service_name_opt.unwrap_or_else(|| {
        config
            .resource
            .get(semcov::resource::SERVICE_NAME)
            .map(|v| v.to_string())
            .unwrap_or_else(|| "unknown_service".to_string())
    });
    // merge the tags and resource. Resources take priority.
    let mut tags = config
        .resource
        .iter()
        .filter(|(key, _)| **key != semcov::resource::SERVICE_NAME)
        .map(|(key, value)| KeyValue::new(key.clone(), value.clone()))
        .collect::<Vec<KeyValue>>();
    tags.push(KeyValue::new(
        semcov::resource::SERVICE_NAME,
        service_name.clone(),
    ));
    (config, Process { service_name, tags })
}
fn build_config_and_process ( config : Option < sdk :: trace :: Config > , service_name_opt : Option < String > , ) -> ( sdk :: trace :: Config , Process ) { let config = config . unwrap_or_default ( ) ; let service_name = service_name_opt . unwrap_or_else ( | | { config . resource . get ( semcov :: resource :: SERVICE_NAME ) . map ( | v | v . to_string ( ) ) . unwrap_or_else ( | | " " . to_string ( ) ) } ) ; // merge the tags and resource. Resources take priority. let mut tags = config . resource . iter ( ) . filter ( | ( key , _ ) | * * key != semcov :: resource :: SERVICE_NAME ) . map ( | ( key , value ) | KeyValue :: new ( key . clone ( ) , value . clone ( ) ) ) . collect :: < Vec < KeyValue > > ( ) ; tags . push ( KeyValue :: new ( semcov :: resource :: SERVICE_NAME , service_name . clone ( ) , ) ) ; ( config , Process { service_name , tags } ) }
To reduce the overhead of copying service name in every spans.
To reduce the overhead of copying service name in every spans .
config
Option<sdk::trace::Config>
service_name_opt
Option<String>
config
Option<sdk::trace::Config>
service_name_opt
Option<String>