fix: Improved getting active tracer and current span mechanism #818
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
get_tracer_tuplefunction is widely used in almost every instrumentation and basically it returns the active_tracer and the parent_span if a root exit span is not expected, otherwise it returns only the active span. If neither the current_span is recording nor a root exit span is expected, it returns None. Before the code change, get_current_span function was called twice, the active_tracer was reached viasingletons.tracerinstead of the tracer getter (get_tracer).tracing_is_offfunction is also widely used in almost every instrumentation and it only returns whether the tracer is ready to record a new span or not. As I already explained above, we already have this information in the tracer, so that by combining these two functions into get_tracer_tuple function, we're getting rid of 1 get_current_span call and functionality oftracing_is_offfunction since we can directly check if the tracer in the instrumentation is False or not.get_active_tracerandtracing_is_offfunctions has been removedrpc-clientspans started being created when the root exit span is enabled for the following instrumentations: