@@ -96,28 +96,7 @@ def finalize(self):
9696
9797 @staticmethod
9898 def _supportability_request (params , payload , body , compression_time ):
99- # *********
100- # Used only for supportability metrics. Do not use to drive business
101- # logic!
102- agent_method = params and params .get ("method" )
103- # *********
104-
105- if agent_method and body :
106- # Compression was applied
107- if compression_time is not None :
108- internal_metric (
109- "Supportability/Python/Collector/ZLIB/Bytes/%s" % agent_method ,
110- len (payload ),
111- )
112- internal_metric (
113- "Supportability/Python/Collector/ZLIB/Compress/%s" % agent_method ,
114- compression_time ,
115- )
116-
117- internal_metric (
118- "Supportability/Python/Collector/Output/Bytes/%s" % agent_method ,
119- len (body ),
120- )
99+ pass
121100
122101 @classmethod
123102 def log_request (
@@ -166,22 +145,7 @@ def log_request(
166145
167146 @staticmethod
168147 def _supportability_response (status , exc , connection = "direct" ):
169- if exc or not 200 <= status < 300 :
170- internal_count_metric ("Supportability/Python/Collector/Failures" , 1 )
171- internal_count_metric (
172- "Supportability/Python/Collector/Failures/%s" % connection , 1
173- )
174-
175- if exc :
176- internal_count_metric (
177- "Supportability/Python/Collector/Exception/"
178- "%s" % callable_name (exc ),
179- 1 ,
180- )
181- else :
182- internal_count_metric (
183- "Supportability/Python/Collector/HTTPError/%d" % status , 1
184- )
148+ pass
185149
186150 @classmethod
187151 def log_response (cls , fp , log_id , status , headers , data , connection = "direct" ):
@@ -544,7 +508,57 @@ def __init__(
544508 )
545509
546510
547- class DeveloperModeClient (BaseClient ):
511+ class SupportabilityMixin (object ):
512+ @staticmethod
513+ def _supportability_request (params , payload , body , compression_time ):
514+ # *********
515+ # Used only for supportability metrics. Do not use to drive business
516+ # logic!
517+ agent_method = params and params .get ("method" )
518+ # *********
519+
520+ if agent_method and body :
521+ # Compression was applied
522+ if compression_time is not None :
523+ internal_metric (
524+ "Supportability/Python/Collector/ZLIB/Bytes/%s" % agent_method ,
525+ len (payload ),
526+ )
527+ internal_metric (
528+ "Supportability/Python/Collector/ZLIB/Compress/%s" % agent_method ,
529+ compression_time ,
530+ )
531+
532+ internal_metric (
533+ "Supportability/Python/Collector/Output/Bytes/%s" % agent_method ,
534+ len (body ),
535+ )
536+
537+ @staticmethod
538+ def _supportability_response (status , exc , connection = "direct" ):
539+ if exc or not 200 <= status < 300 :
540+ internal_count_metric ("Supportability/Python/Collector/Failures" , 1 )
541+ internal_count_metric (
542+ "Supportability/Python/Collector/Failures/%s" % connection , 1
543+ )
544+
545+ if exc :
546+ internal_count_metric (
547+ "Supportability/Python/Collector/Exception/"
548+ "%s" % callable_name (exc ),
549+ 1 ,
550+ )
551+ else :
552+ internal_count_metric (
553+ "Supportability/Python/Collector/HTTPError/%d" % status , 1
554+ )
555+
556+
557+ class ApplicationModeClient (SupportabilityMixin , HttpClient ):
558+ pass
559+
560+
561+ class DeveloperModeClient (SupportabilityMixin , BaseClient ):
548562 RESPONSES = {
549563 "preconnect" : {u"redirect_host" : u"fake-collector.newrelic.com" },
550564 "agent_settings" : [],
0 commit comments