@@ -16,7 +16,6 @@ use opentelemetry_sdk::{
1616 Resource ,
1717} ;
1818use opentelemetry_semantic_conventions as semcov;
19- use std:: borrow:: Cow ;
2019use std:: net:: SocketAddr ;
2120use std:: sync:: Arc ;
2221use std:: time:: Duration ;
@@ -89,22 +88,21 @@ impl ZipkinPipelineBuilder {
8988 ///
9089 /// Returns error if the endpoint is not valid or if no http client is provided.
9190 pub fn init_exporter ( mut self ) -> Result < Exporter , TraceError > {
92- let ( _, endpoint) = self . init_config_and_endpoint ( ) ;
91+ let ( _, endpoint) = self . init_resource_and_endpoint ( ) ;
9392 self . init_exporter_with_endpoint ( endpoint)
9493 }
9594
96- fn init_config_and_endpoint ( & mut self ) -> ( Resource , Endpoint ) {
95+ fn init_resource_and_endpoint ( & mut self ) -> ( Resource , Endpoint ) {
9796 let service_name = self . service_name . take ( ) ;
9897 if let Some ( service_name) = service_name {
99- let resource = if let Some ( mut cfg) = self . trace_config . take ( ) {
100- cfg . resource = Cow :: Owned ( Resource :: new (
98+ let resource = if let Some ( cfg) = & self . trace_config {
99+ Resource :: new (
101100 cfg. resource
102101 . iter ( )
103102 . filter ( |( k, _v) | k. as_str ( ) != semcov:: resource:: SERVICE_NAME )
104103 . map ( |( k, v) | KeyValue :: new ( k. clone ( ) , v. clone ( ) ) )
105104 . collect :: < Vec < KeyValue > > ( ) ,
106- ) ) ;
107- cfg. resource . as_ref ( ) . clone ( )
105+ )
108106 } else {
109107 Resource :: empty ( )
110108 } ;
@@ -139,7 +137,7 @@ impl ZipkinPipelineBuilder {
139137
140138 /// Install the Zipkin trace exporter pipeline with a simple span processor.
141139 pub fn install_simple ( mut self ) -> Result < Tracer , TraceError > {
142- let ( resource, endpoint) = self . init_config_and_endpoint ( ) ;
140+ let ( resource, endpoint) = self . init_resource_and_endpoint ( ) ;
143141 let exporter = self . init_exporter_with_endpoint ( endpoint) ?;
144142 let provider = TracerProvider :: builder ( )
145143 . with_simple_exporter ( exporter)
@@ -157,7 +155,7 @@ impl ZipkinPipelineBuilder {
157155 /// Install the Zipkin trace exporter pipeline with a batch span processor using the specified
158156 /// runtime.
159157 pub fn install_batch < R : RuntimeChannel > ( mut self , runtime : R ) -> Result < Tracer , TraceError > {
160- let ( resource, endpoint) = self . init_config_and_endpoint ( ) ;
158+ let ( resource, endpoint) = self . init_resource_and_endpoint ( ) ;
161159 let exporter = self . init_exporter_with_endpoint ( endpoint) ?;
162160 let provider = TracerProvider :: builder ( )
163161 . with_batch_exporter ( exporter, runtime)
0 commit comments