question

97278016 avatar image
0 Votes"
97278016 asked MayankBargali-MSFT answered

How to log Response time to Event hubs using apim policies

<log-to-eventhub logger-id="logger">@{
var content = new JObject();
content["EventTime"] = DateTime.UtcNow.ToString();
content["ServiceName"] = context.Deployment.ServiceName;
content["RequestId"] = context.RequestId;
content["RequestIp"] = context.Request.IpAddress;
content["OperationName"] = context.Operation.Name;
content["resBody"] = context.Response.Body.As<string>(true);
return content.ToString();
}</log-to-eventhub>

I have added above code in the azure apim policies, it is working perfectly fine. I wanted to add "Response time" to event hub. Which attribute to be used to log Response duration to event hubs?

azure-api-managementazure-event-hubs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MayankBargali-MSFT avatar image
1 Vote"
MayankBargali-MSFT answered

@ParameshwaragowdaNischithaBTCustom-9530 There are no configuration/attributes in log-to-eventhub policy that can help in your scenario.
As imagine senario where your service processing millions of API calls per second, each of which has a log-to-eventhub. Its designed this way so we don't block the API call and add messages to a queue that can be sent and retried as needed.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.