@@ -30,8 +30,8 @@ def __init__(self, api_key, root_url="https://app.apitoolkit.io", redact_headers
30
30
if response .status_code == 401 :
31
31
raise Exception (f"APIToolkit Error: Invalid API key" )
32
32
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 :
35
35
data = response .json ()
36
36
credentials = service_account .Credentials .from_service_account_info (
37
37
data ["pubsub_push_service_account" ])
@@ -123,8 +123,8 @@ def afterRequest(self, response):
123
123
if self .meta is None :
124
124
if self .debug :
125
125
print ("APIToolkit: Project ID not set (restart your server to fix)" )
126
- return
127
-
126
+ return
127
+
128
128
end_time = time .perf_counter_ns ()
129
129
apitoolkit_request_data = g .get ("apitoolkit_request_data" , {})
130
130
duration = (end_time - apitoolkit_request_data .get ("start_time" , 0 ))
@@ -134,8 +134,11 @@ def afterRequest(self, response):
134
134
response_headers = self .redact_headers_func (dict (response .headers ))
135
135
request_body = self .redact_fields (
136
136
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 (
138
140
response .data , self .redact_response_body )
141
+
139
142
timezone = pytz .timezone ("UTC" )
140
143
timestamp = datetime .now (timezone ).isoformat ()
141
144
message_id = request .apitoolkit_message_id
@@ -168,4 +171,4 @@ def afterRequest(self, response):
168
171
return None
169
172
def handle_error (self , e ):
170
173
if not isinstance (e , HTTPException ):
171
- report_error (request , e )
174
+ report_error (request , e )
0 commit comments