2929ATTRIBUTE_ERROR_MESSAGE = 'ERROR_MESSAGE'
3030GRPC_HOST_PORT = 'GRPC_HOST_PORT'
3131GRPC_METHOD = 'GRPC_METHOD'
32+ SENT_PREFIX = 'Sent'
3233
3334TIMEOUT = 3
3435
@@ -57,9 +58,10 @@ def __init__(self, tracer=None, host_port=None):
5758 self .host_port = host_port
5859 self ._propagator = binary_format .BinaryFormatPropagator ()
5960
60- def _start_client_span (self , method , grpc_type ):
61+ def _start_client_span (self , client_call_details ):
6162 span = self ._tracer .start_span (
62- name = '[gRPC_client][{}]{}' .format (grpc_type , str (method )))
63+ name = _get_span_name (client_call_details )
64+ )
6365
6466 # Add the component grpc to span attribute
6567 self ._tracer .add_attribute_to_current_span (
@@ -76,7 +78,7 @@ def _start_client_span(self, method, grpc_type):
7678 # Add the method to span attribute
7779 self ._tracer .add_attribute_to_current_span (
7880 attribute_key = attributes_helper .GRPC_ATTRIBUTES .get (GRPC_METHOD ),
79- attribute_value = str (method ))
81+ attribute_value = str (client_call_details . method ))
8082
8183 return span
8284
@@ -91,9 +93,7 @@ def _intercept_call(
9193 metadata = client_call_details .metadata
9294
9395 # Start a span
94- current_span = self ._start_client_span (
95- client_call_details .method ,
96- grpc_type )
96+ current_span = self ._start_client_span (client_call_details )
9797
9898 span_context = self ._tracer .span_context
9999 header = self ._propagator .to_header (span_context )
@@ -211,3 +211,9 @@ def intercept_stream_stream(self, continuation, client_call_details,
211211 self ._end_span_between_context (current_span )
212212
213213 return response_it
214+
215+
216+ def _get_span_name (client_call_details ):
217+ """Generates a span name based off of the gRPC client call details"""
218+ method_name = client_call_details .method [1 :].replace ('/' , '.' )
219+ return '{}.{}' .format (SENT_PREFIX , method_name )
0 commit comments