LogRequest is not logging the correct start-time #356
Labels
application-insights
All issues related to Azure Application Insights
enhancement
New feature or request
requests
All issues related to requests
Milestone
This is related to arcus-azure/arcus.webapi#310
When calling
LogRequest
, the timestamp at which the request was started, is not correctly logged. (See the related issue for more detailed information).This is because the
LogRequest
method does not contain a parameter that represents thestartDateTime
, and further up the chain,DateTimeOffset.UtcNow
is used for determining the start-date of the request, which is obviously wrong, as the time at which you call thisLogRequest
method, is not necessarily at the time the request starts.To fix this, we need to pass in the correct request-starttime to the
LogRequest
method. There are different approaches for this:add yet another parameter to the
LogRequest
method which represents the start-time of the request. Drawback of this approach is that the method signature becomes bloated. ExistingLogRequest
overloads can call the newly introduced version and pass inDateTimeOffset.UtcNow
as start-time. However, these existing methods should be marked as obsolete imho.Instead of passing in a
Timespan
parameter to represent the duration, we could pass in aDurationMeasurement
type. We would then also need to extend theDurationMeasurement
so that it contains aStartedAt
orStartDateTime
property which returns the start-timestamp of the measurement. Drawback of this solution is that people need to pass in aDurationMeasurement
, and that might not always be available. (This can offcourse be solved by making sure that we can instantiateDurationMeasurement
instances by passing in a DateTimeOffset and a Timespan when constructing it. (Either via a constructor or via a factory method).We can pass - in the start-datetime as a property in the
context
parameter, but that is just implicit and not favorable.The text was updated successfully, but these errors were encountered: