src/Arcus.Shared/Observability/Sinks/Converters/SuperCustomRequestTelemetryConverter.cs
/// <summary>
///     Creates a telemetry entry for a given log event
/// </summary>
/// <param name="logEvent">Event that was logged and written to this sink</param>
/// <param name="formatProvider">Provider to format event</param>
/// <returns>Telemetry entry to emit to Azure Application Insights</returns>
Creates a telemetry entry for a given log event
Creates a telemetry entry for a given log event
protected override RequestTelemetry CreateTelemetryEntry(LogEvent logEvent, IFormatProvider formatProvider)
        {
            var requestMethod = logEvent.Properties.GetAsRawString(ContextProperties.RequestTracking.RequestMethod);
            var requestHost = logEvent.Properties.GetAsRawString(ContextProperties.RequestTracking.RequestHost);
            var requestUri = logEvent.Properties.GetAsRawString(ContextProperties.RequestTracking.RequestUri);
            var responseStatusCode = logEvent.Properties.GetAsRawString(ContextProperties.RequestTracking.ResponseStatusCode);
            var requestDuration = logEvent.Properties.GetAsTimeSpan(ContextProperties.RequestTracking.RequestDuration);
            var requestTime = logEvent.Properties.GetAsDateTimeOffset(ContextProperties.RequestTracking.RequestTime);
            var operationId = logEvent.Properties.GetAsRawString(ContextProperties.Correlation.OperationId);
            var requestName = $"{requestMethod} {requestUri}";
            var isSuccessfulRequest = DetermineRequestOutcome(responseStatusCode);
            var url = new Uri($"{requestHost}{requestUri}");
            var requestTelemetry = new RequestTelemetry(requestName, requestTime, requestDuration, responseStatusCode, isSuccessfulRequest)
            {
                Id = operationId,
                Url = url
            };
            return requestTelemetry;
        }
protected override RequestTelemetry CreateTelemetryEntry ( LogEvent logEvent , IFormatProvider formatProvider ) { var requestMethod = logEvent . Properties . GetAsRawString ( ContextProperties . RequestTracking . RequestMethod ) ; var requestHost = logEvent . Properties . GetAsRawString ( ContextProperties . RequestTracking . RequestHost ) ; var requestUri = logEvent . Properties . GetAsRawString ( ContextProperties . RequestTracking . RequestUri ) ; var responseStatusCode = logEvent . Properties . GetAsRawString ( ContextProperties . RequestTracking . ResponseStatusCode ) ; var requestDuration = logEvent . Properties . GetAsTimeSpan ( ContextProperties . RequestTracking . RequestDuration ) ; var requestTime = logEvent . Properties . GetAsDateTimeOffset ( ContextProperties . RequestTracking . RequestTime ) ; var operationId = logEvent . Properties . GetAsRawString ( ContextProperties . Correlation . OperationId ) ; var requestName = $" { requestMethod } { requestUri } " ; var isSuccessfulRequest = DetermineRequestOutcome ( responseStatusCode ) ; var url = new Uri ( $" { requestHost } { requestUri } " ) ; var requestTelemetry = new RequestTelemetry ( requestName , requestTime , requestDuration , responseStatusCode , isSuccessfulRequest ) { Id = operationId , Url = url } ; return requestTelemetry ; }
Creates a telemetry entry for a given log event
Creates a telemetry entry for a given log event
Telemetry entry to emit to Azure Application Insights
Telemetry entry to emit to Azure Application Insights
logEvent
LogEvent
Event that was logged and written to this sink
Event that was logged and written to this sink
formatProvider
IFormatProvider
Provider to format event
Provider to format event