1717
1818from opencensus .trace .ext import utils
1919from opencensus .trace .ext .django .config import (settings , convert_to_import )
20- from opencensus .trace import labels_helper
20+ from opencensus .trace import attributes_helper
2121from opencensus .trace import request_tracer
2222from opencensus .trace import execution_context
2323from opencensus .trace .samplers import probability
2727except ImportError : # pragma: NO COVER
2828 MiddlewareMixin = object
2929
30- HTTP_METHOD = labels_helper . COMMON_LABELS ['HTTP_METHOD' ]
31- HTTP_URL = labels_helper . COMMON_LABELS ['HTTP_URL' ]
32- HTTP_STATUS_CODE = labels_helper . COMMON_LABELS ['HTTP_STATUS_CODE' ]
30+ HTTP_METHOD = attributes_helper . COMMON_ATTRIBUTES ['HTTP_METHOD' ]
31+ HTTP_URL = attributes_helper . COMMON_ATTRIBUTES ['HTTP_URL' ]
32+ HTTP_STATUS_CODE = attributes_helper . COMMON_ATTRIBUTES ['HTTP_STATUS_CODE' ]
3333
3434REQUEST_THREAD_LOCAL_KEY = 'django_request'
3535
@@ -61,8 +61,8 @@ def _get_current_request_tracer():
6161 return execution_context .get_opencensus_tracer ()
6262
6363
64- def _set_django_labels (tracer , request ):
65- """Set the django related labels ."""
64+ def _set_django_attributes (tracer , request ):
65+ """Set the django related attributes ."""
6666 django_user = getattr (request , 'user' , None )
6767
6868 if django_user is None :
@@ -73,10 +73,10 @@ def _set_django_labels(tracer, request):
7373
7474 # User id is the django autofield for User model as the primary key
7575 if user_id is not None :
76- tracer .add_label_to_current_span ('/django/user/id' , str (user_id ))
76+ tracer .add_attribute_to_current_span ('/django/user/id' , str (user_id ))
7777
7878 if user_name is not None :
79- tracer .add_label_to_current_span ('/django/user/name' , user_name )
79+ tracer .add_attribute_to_current_span ('/django/user/name' , user_name )
8080
8181
8282def get_django_header ():
@@ -167,12 +167,12 @@ def process_request(self, request):
167167
168168 # Span name is being set at process_view
169169 tracer .start_span ()
170- tracer .add_label_to_current_span (
171- label_key = HTTP_METHOD ,
172- label_value = request .method )
173- tracer .add_label_to_current_span (
174- label_key = HTTP_URL ,
175- label_value = request .path )
170+ tracer .add_attribute_to_current_span (
171+ attribute_key = HTTP_METHOD ,
172+ attribute_value = request .method )
173+ tracer .add_attribute_to_current_span (
174+ attribute_key = HTTP_URL ,
175+ attribute_value = request .path )
176176 except Exception : # pragma: NO COVER
177177 log .error ('Failed to trace request' , exc_info = True )
178178
@@ -200,11 +200,11 @@ def process_response(self, request, response):
200200
201201 try :
202202 tracer = _get_current_request_tracer ()
203- tracer .add_label_to_current_span (
204- label_key = HTTP_STATUS_CODE ,
205- label_value = str (response .status_code ))
203+ tracer .add_attribute_to_current_span (
204+ attribute_key = HTTP_STATUS_CODE ,
205+ attribute_value = str (response .status_code ))
206206
207- _set_django_labels (tracer , request )
207+ _set_django_attributes (tracer , request )
208208
209209 tracer .end_span ()
210210 tracer .finish ()
0 commit comments