get some more insight into connector proxy timings

This commit is contained in:
burnettk 2023-02-01 13:30:45 -05:00
parent 48781039c7
commit e460325e60

View File

@ -3,6 +3,7 @@ import json
from typing import Any from typing import Any
import requests import requests
import sentry_sdk
from flask import current_app from flask import current_app
from flask import g from flask import g
@ -45,27 +46,27 @@ class ServiceTaskDelegate:
@staticmethod @staticmethod
def call_connector(name: str, bpmn_params: Any, task_data: Any) -> str: def call_connector(name: str, bpmn_params: Any, task_data: Any) -> str:
"""Calls a connector via the configured proxy.""" """Calls a connector via the configured proxy."""
params = { call_url = f"{connector_proxy_url()}/v1/do/{name}"
k: ServiceTaskDelegate.check_prefixes(v["value"]) with sentry_sdk.start_transaction(op="call-connector", name=call_url):
for k, v in bpmn_params.items() params = {
} k: ServiceTaskDelegate.check_prefixes(v["value"])
params["spiff__task_data"] = task_data for k, v in bpmn_params.items()
}
params["spiff__task_data"] = task_data
proxied_response = requests.post( proxied_response = requests.post(call_url, json=params)
f"{connector_proxy_url()}/v1/do/{name}", json=params
)
parsed_response = json.loads(proxied_response.text) parsed_response = json.loads(proxied_response.text)
if "refreshed_token_set" not in parsed_response: if "refreshed_token_set" not in parsed_response:
return proxied_response.text return proxied_response.text
secret_key = parsed_response["auth"] secret_key = parsed_response["auth"]
refreshed_token_set = json.dumps(parsed_response["refreshed_token_set"]) refreshed_token_set = json.dumps(parsed_response["refreshed_token_set"])
user_id = g.user.id if UserService.has_user() else None user_id = g.user.id if UserService.has_user() else None
SecretService().update_secret(secret_key, refreshed_token_set, user_id) SecretService().update_secret(secret_key, refreshed_token_set, user_id)
return json.dumps(parsed_response["api_response"]) return json.dumps(parsed_response["api_response"])
class ServiceTaskService: class ServiceTaskService: