@@ -30,8 +30,8 @@ def __init__(self, api_key, root_url="https://app.apitoolkit.io", redact_headers
3030 if response .status_code == 401 :
3131 raise Exception (f"APIToolkit Error: Invalid API key" )
3232 elif response .status_code >= 400 :
33- print (f"APIToolkit: Error getting client metadata { response .status_code } " )
34- else :
33+ print (f"APIToolkit: Error getting client metadata { response .status_code } " )
34+ else :
3535 data = response .json ()
3636 credentials = service_account .Credentials .from_service_account_info (
3737 data ["pubsub_push_service_account" ])
@@ -123,8 +123,8 @@ def afterRequest(self, response):
123123 if self .meta is None :
124124 if self .debug :
125125 print ("APIToolkit: Project ID not set (restart your server to fix)" )
126- return
127-
126+ return
127+
128128 end_time = time .perf_counter_ns ()
129129 apitoolkit_request_data = g .get ("apitoolkit_request_data" , {})
130130 duration = (end_time - apitoolkit_request_data .get ("start_time" , 0 ))
@@ -134,8 +134,11 @@ def afterRequest(self, response):
134134 response_headers = self .redact_headers_func (dict (response .headers ))
135135 request_body = self .redact_fields (
136136 request_body , self .redact_request_body )
137- response_body = self .redact_fields (
137+ response_body = ""
138+ if not response .direct_passthrough :
139+ response_body = self .redact_fields (
138140 response .data , self .redact_response_body )
141+
139142 timezone = pytz .timezone ("UTC" )
140143 timestamp = datetime .now (timezone ).isoformat ()
141144 message_id = request .apitoolkit_message_id
@@ -168,4 +171,4 @@ def afterRequest(self, response):
168171 return None
169172 def handle_error (self , e ):
170173 if not isinstance (e , HTTPException ):
171- report_error (request , e )
174+ report_error (request , e )
0 commit comments