@@ -705,19 +705,22 @@ class _Span(Span):
705
705
706
706
class Tracer (trace_api .Tracer ):
707
707
"""See `opentelemetry.trace.Tracer`.
708
-
709
- Args:
710
- name: The name of the tracer.
711
- shutdown_on_exit: Register an atexit hook to shut down the tracer when
712
- the application exits.
713
708
"""
714
709
715
710
def __init__ (
716
711
self ,
717
- source : "TracerProvider" ,
712
+ sampler : sampling .Sampler ,
713
+ resource : Resource ,
714
+ span_processor : Union [
715
+ SynchronousMultiSpanProcessor , ConcurrentMultiSpanProcessor
716
+ ],
717
+ ids_generator : trace_api .IdsGenerator ,
718
718
instrumentation_info : InstrumentationInfo ,
719
719
) -> None :
720
- self .source = source
720
+ self .sampler = sampler
721
+ self .resource = resource
722
+ self .span_processor = span_processor
723
+ self .ids_generator = ids_generator
721
724
self .instrumentation_info = instrumentation_info
722
725
723
726
def start_as_current_span (
@@ -759,7 +762,7 @@ def start_span( # pylint: disable=too-many-locals
759
762
# is_valid determines root span
760
763
if parent_span_context is None or not parent_span_context .is_valid :
761
764
parent_span_context = None
762
- trace_id = self .source . ids_generator .generate_trace_id ()
765
+ trace_id = self .ids_generator .generate_trace_id ()
763
766
trace_flags = None
764
767
trace_state = None
765
768
else :
@@ -772,7 +775,7 @@ def start_span( # pylint: disable=too-many-locals
772
775
# exported.
773
776
# The sampler may also add attributes to the newly-created span, e.g.
774
777
# to include information about the sampling result.
775
- sampling_result = self .source . sampler .should_sample (
778
+ sampling_result = self .sampler .should_sample (
776
779
context , trace_id , name , attributes , links ,
777
780
)
778
781
@@ -783,7 +786,7 @@ def start_span( # pylint: disable=too-many-locals
783
786
)
784
787
span_context = trace_api .SpanContext (
785
788
trace_id ,
786
- self .source . ids_generator .generate_span_id (),
789
+ self .ids_generator .generate_span_id (),
787
790
is_remote = False ,
788
791
trace_flags = trace_flags ,
789
792
trace_state = trace_state ,
@@ -796,10 +799,10 @@ def start_span( # pylint: disable=too-many-locals
796
799
name = name ,
797
800
context = span_context ,
798
801
parent = parent_span_context ,
799
- sampler = self .source . sampler ,
800
- resource = self .source . resource ,
802
+ sampler = self .sampler ,
803
+ resource = self .resource ,
801
804
attributes = sampling_result .attributes .copy (),
802
- span_processor = self .source . _active_span_processor ,
805
+ span_processor = self .span_processor ,
803
806
kind = kind ,
804
807
links = links ,
805
808
instrumentation_info = self .instrumentation_info ,
@@ -888,7 +891,10 @@ def get_tracer(
888
891
instrumenting_module_name = "ERROR:MISSING MODULE NAME"
889
892
logger .error ("get_tracer called with missing module name." )
890
893
return Tracer (
891
- self ,
894
+ self .sampler ,
895
+ self .resource ,
896
+ self ._active_span_processor ,
897
+ self .ids_generator ,
892
898
InstrumentationInfo (
893
899
instrumenting_module_name , instrumenting_library_version
894
900
),
0 commit comments