I want to run Azure Durable Functions and measure the response time taken from the time the trigger is pulled to the time it returns.
The sequence of events I want to measure is as follows
The reason why I want to do this is to investigate how the response time of Durable Functions is affected when the size of data transferred by the orchestration function and the activity function is different.
How can I measure the time between the trigger being pulled and the response being received in Azure Portal or Applications Insights?
The environment I am using is, Azure Free Tier Python programming model v2
I have deployed the below code to Azure Function App.
import azure.functions as func
import azure.durable_functions as df
import logging
import numpy as np
import pickle
app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
### client function ###
@app.route(route="orchestrators/client_function")
@app.durable_client_input(client_name="client")
async def client_function(req: func.HttpRequest, client: df.DurableOrchestrationClient) -> func.HttpResponse:
instance_id = await client.start_new("orchestrator", None, {})
logging.info(f"Started orchestration with ID = '{instance_id}'.")
await client.wait_for_completion_or_create_check_status_response(req, instance_id)
status = await client.get_status(instance_id)
runtime = status.runtime_status
output = status.output
return f"runtime: {runtime}\n\noutput:{output}"
@app.orchestration_trigger(context_name="context")
def orchestrator(context: df.DurableOrchestrationContext):
result = yield context.call_activity("activity1", "")
return result
@app.activity_trigger(input_name="blank")
def activity1(blank: str) -> str:
data = np.random.rand(1024 * 1024 * 5)
serialized_data = pickle.dumps(data)
serialized_size = len(serialized_data)
return str(serialized_size)
Post deployment, I am able to see the functions in function app.
Then, I invoked the Http Trigger function.
There are multiple ways you can check the total time taken by Http function to complete the execution.
You can also graphically visualize the execution in vs code using Durable Function Monitor extension.
Install the Durable Function Monitor extension in vs code and then connect to your function app. You can refer to this link to know more about the mentioned extension.